Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Validators\MembershipValidator Class Reference

MembershipValidator checks that a value is in a fixed set of allowed values. More...

+ Inheritance diagram for Wikibase\Repo\Validators\MembershipValidator:
+ Collaboration diagram for Wikibase\Repo\Validators\MembershipValidator:

Public Member Functions

 __construct (array $allowed, $errorCode='not-allowed', $normalizer=null)
 
 validate ( $value)
 
 setOptions (array $options)
 

Private Attributes

 $allowed
 
 $errorCode
 
 $normalizer
 

Detailed Description

MembershipValidator checks that a value is in a fixed set of allowed values.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Validators\MembershipValidator::__construct ( array  $allowed,
  $errorCode = 'not-allowed',
  $normalizer = null 
)
Parameters
string[]$allowedThe allowed values
string$errorCodeCode to use in Errors; should indicate what kind of value would have been allowed.
callable | string | null$normalizerAn optional function to normalize the value before comparing it to the list of allowed values, e.g. 'strtolower'.
Exceptions
InvalidArgumentException

Member Function Documentation

◆ setOptions()

Wikibase\Repo\Validators\MembershipValidator::setOptions ( array  $options)
See also
ValueValidator::setOptions
Parameters
array$options

◆ validate()

Wikibase\Repo\Validators\MembershipValidator::validate (   $value)
See also
ValueValidator::validate
Parameters
string$valueThe value to validate
Returns
Result

Member Data Documentation

◆ $allowed

Wikibase\Repo\Validators\MembershipValidator::$allowed
private

◆ $errorCode

Wikibase\Repo\Validators\MembershipValidator::$errorCode
private

◆ $normalizer

Wikibase\Repo\Validators\MembershipValidator::$normalizer
private

The documentation for this class was generated from the following file: