MediaWiki
1.34.0
|
Type definition for enumeration types. More...
Public Member Functions | |
getEnumValues ( $name, array $settings, array $options) | |
Get the values for enum-like parameters. More... | |
stringifyValue ( $name, $value, array $settings, array $options) | |
Convert a value to a string representation. More... | |
validate ( $name, $value, array $settings, array $options) | |
Validate the value. More... | |
Public Member Functions inherited from Wikimedia\ParamValidator\TypeDef | |
__construct (Callbacks $callbacks) | |
describeSettings ( $name, array $settings, array $options) | |
"Describe" a settings array More... | |
getValue ( $name, array $settings, array $options) | |
Get the value from the request. More... | |
normalizeSettings (array $settings) | |
Normalize a settings array. More... | |
Public Attributes | |
const | PARAM_DEPRECATED_VALUES = 'param-deprecated-values' |
(array) Associative array of deprecated values. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Wikimedia\ParamValidator\TypeDef | |
Callbacks | $callbacks |
Type definition for enumeration types.
This class expects that PARAM_TYPE is an array of allowed values. Subclasses may override getEnumValues() to determine the allowed values differently.
The result from validate() is one of the defined values.
ValidationException codes:
Additional codes may be generated when using certain PARAM constants. See the constants' documentation for details.
Definition at line 28 of file EnumDef.php.
Wikimedia\ParamValidator\TypeDef\EnumDef::getEnumValues | ( | $name, | |
array | $settings, | ||
array | $options | ||
) |
Get the values for enum-like parameters.
This is primarily intended for documentation and implementation of PARAM_ALL; it is the responsibility of the TypeDef to ensure that validate() accepts the values returned here.
string | $name | Parameter name being validated. |
array | $settings | Parameter settings array. |
array | $options | Options array. |
Reimplemented from Wikimedia\ParamValidator\TypeDef.
Definition at line 72 of file EnumDef.php.
References Wikimedia\ParamValidator\ParamValidator\PARAM_TYPE.
Referenced by Wikimedia\ParamValidator\TypeDef\EnumDef\validate().
Wikimedia\ParamValidator\TypeDef\EnumDef::stringifyValue | ( | $name, | |
$value, | |||
array | $settings, | ||
array | $options | ||
) |
Convert a value to a string representation.
This is intended as the inverse of getValue() and validate(): this should accept anything returned by those methods or expected to be used as PARAM_DEFAULT, and if the string from this method is passed in as client input or PARAM_DEFAULT it should give equivalent output from validate().
string | $name | Parameter name being converted. |
mixed | $value | Parameter value being converted. Do not pass null. |
array | $settings | Parameter settings array. |
array | $options | Options array. |
Reimplemented from Wikimedia\ParamValidator\TypeDef.
Definition at line 76 of file EnumDef.php.
Wikimedia\ParamValidator\TypeDef\EnumDef::validate | ( | $name, | |
$value, | |||
array | $settings, | ||
array | $options | ||
) |
Validate the value.
When ParamValidator is processing a multi-valued parameter, this will be called once for each of the supplied values. Which may mean zero calls.
When getValue() returned null, this will not be called.
string | $name | Parameter name being validated. |
mixed | $value | Value to validate, from getValue(). |
array | $settings | Parameter settings array. |
array | $options | Options array. Note the following values that may be set by ParamValidator:
|
ValidationException | if the value is invalid |
Reimplemented from Wikimedia\ParamValidator\TypeDef.
Definition at line 46 of file EnumDef.php.
References Wikimedia\ParamValidator\ParamValidator\explodeMultiValue(), and Wikimedia\ParamValidator\TypeDef\EnumDef\getEnumValues().
const Wikimedia\ParamValidator\TypeDef\EnumDef::PARAM_DEPRECATED_VALUES = 'param-deprecated-values' |
(array) Associative array of deprecated values.
Keys are the deprecated parameter values, values are included in the ValidationException. If value is null, the parameter is considered not actually deprecated.
Note that this does not add any values to the enumeration, it only documents existing values as being deprecated.
ValidationException codes: (non-fatal)
Definition at line 44 of file EnumDef.php.