MediaWiki
1.34.0
|
Type definition for checkbox-like boolean types. More...
Public Member Functions | |
describeSettings ( $name, array $settings, array $options) | |
"Describe" a settings array More... | |
getValue ( $name, array $settings, array $options) | |
Get the value from the request. More... | |
validate ( $name, $value, array $settings, array $options) | |
Validate the value. More... | |
Public Member Functions inherited from Wikimedia\ParamValidator\TypeDef | |
__construct (Callbacks $callbacks) | |
getEnumValues ( $name, array $settings, array $options) | |
Get the values for enum-like parameters. More... | |
normalizeSettings (array $settings) | |
Normalize a settings array. More... | |
stringifyValue ( $name, $value, array $settings, array $options) | |
Convert a value to a string representation. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Wikimedia\ParamValidator\TypeDef | |
Callbacks | $callbacks |
Type definition for checkbox-like boolean types.
This boolean is considered true if the parameter is present in the request, regardless of value. The only way for it to be false is for the parameter to be omitted entirely.
The result from validate() is a PHP boolean.
Definition at line 19 of file PresenceBooleanDef.php.
Wikimedia\ParamValidator\TypeDef\PresenceBooleanDef::describeSettings | ( | $name, | |
array | $settings, | ||
array | $options | ||
) |
"Describe" a settings array
This is intended to format data about a settings array using this type in a way that would be useful for automatically generated documentation or a machine-readable interface specification.
Keys in the description array should follow the same guidelines as the code described for ValidationException.
By default, each value in the description array is a single string, integer, or array. When ‘$options['compact’]` is supplied, each value is instead an array of such and related values may be combined. For example, a non-compact description for an integer type might include ‘[ 'default’ => 0, 'min' => 0, 'max' => 5 ], while in compact mode it might instead report
[ 'default' => [ 'value' => 0 ], 'minmax' => [ 'min' => 0, 'max' => 5 ] ]‘ to facilitate auto-generated documentation turning that 'minmax’ into "Value must be between 0 and 5" rather than disconnected statements "Value must be >= 0" and "Value must be <= 5".
string | $name | Parameter name being described. |
array | $settings | Parameter settings array. |
array | $options | Options array. Defined options for this base class are:
|
Reimplemented from Wikimedia\ParamValidator\TypeDef.
Definition at line 29 of file PresenceBooleanDef.php.
Wikimedia\ParamValidator\TypeDef\PresenceBooleanDef::getValue | ( | $name, | |
array | $settings, | ||
array | $options | ||
) |
Get the value from the request.
string | $name | Parameter name being fetched. |
array | $settings | Parameter settings array. |
array | $options | Options array. |
Reimplemented from Wikimedia\ParamValidator\TypeDef.
Definition at line 21 of file PresenceBooleanDef.php.
Wikimedia\ParamValidator\TypeDef\PresenceBooleanDef::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 25 of file PresenceBooleanDef.php.