MediaWiki
1.34.0
|
Type definition for integer types. More...
Public Member Functions | |
describeSettings ( $name, array $settings, array $options) | |
"Describe" a settings array More... | |
normalizeSettings (array $settings) | |
Normalize a settings array. 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... | |
getValue ( $name, array $settings, array $options) | |
Get the value from the request. More... | |
stringifyValue ( $name, $value, array $settings, array $options) | |
Convert a value to a string representation. More... | |
Public Attributes | |
const | PARAM_IGNORE_RANGE = 'param-ignore-range' |
(bool) Whether to enforce the specified range. More... | |
const | PARAM_MAX = 'param-max' |
(int) Maximum allowed value (normal limits) More... | |
const | PARAM_MAX2 = 'param-max2' |
(int) Maximum allowed value (high limits) More... | |
const | PARAM_MIN = 'param-min' |
(int) Minimum allowed value. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Wikimedia\ParamValidator\TypeDef | |
Callbacks | $callbacks |
Type definition for integer types.
A valid representation consists of an optional sign (+
or -
) followed by one or more decimal digits.
The result from validate() is a PHP integer.
Additional codes may be generated when using certain PARAM constants. See the constants' documentation for details.
Definition at line 26 of file IntegerDef.php.
Wikimedia\ParamValidator\TypeDef\IntegerDef::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 134 of file IntegerDef.php.
References Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX, Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX2, and Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MIN.
Wikimedia\ParamValidator\TypeDef\IntegerDef::normalizeSettings | ( | array | $settings | ) |
Normalize a settings array.
array | $settings |
Reimplemented from Wikimedia\ParamValidator\TypeDef.
Reimplemented in Wikimedia\ParamValidator\TypeDef\LimitDef.
Definition at line 120 of file IntegerDef.php.
References Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX, and Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX2.
Wikimedia\ParamValidator\TypeDef\IntegerDef::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.
Reimplemented in Wikimedia\ParamValidator\TypeDef\LimitDef.
Definition at line 72 of file IntegerDef.php.
References Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX, Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MAX2, and Wikimedia\ParamValidator\TypeDef\IntegerDef\PARAM_MIN.
const Wikimedia\ParamValidator\TypeDef\IntegerDef::PARAM_IGNORE_RANGE = 'param-ignore-range' |
(bool) Whether to enforce the specified range.
If set and truthy, ValidationExceptions from PARAM_MIN, PARAM_MAX, and PARAM_MAX2 are non-fatal.
Definition at line 34 of file IntegerDef.php.
const Wikimedia\ParamValidator\TypeDef\IntegerDef::PARAM_MAX = 'param-max' |
(int) Maximum allowed value (normal limits)
ValidationException codes:
Definition at line 56 of file IntegerDef.php.
Referenced by Wikimedia\ParamValidator\TypeDef\IntegerDef\describeSettings(), Wikimedia\ParamValidator\TypeDef\IntegerDef\normalizeSettings(), Wikimedia\ParamValidator\TypeDef\LimitDef\validate(), and Wikimedia\ParamValidator\TypeDef\IntegerDef\validate().
const Wikimedia\ParamValidator\TypeDef\IntegerDef::PARAM_MAX2 = 'param-max2' |
(int) Maximum allowed value (high limits)
If not specified, PARAM_MAX will be enforced for all users. Ignored if PARAM_MAX is not set.
ValidationException codes:
Definition at line 70 of file IntegerDef.php.
Referenced by Wikimedia\ParamValidator\TypeDef\IntegerDef\describeSettings(), Wikimedia\ParamValidator\TypeDef\IntegerDef\normalizeSettings(), Wikimedia\ParamValidator\TypeDef\LimitDef\validate(), and Wikimedia\ParamValidator\TypeDef\IntegerDef\validate().
const Wikimedia\ParamValidator\TypeDef\IntegerDef::PARAM_MIN = 'param-min' |
(int) Minimum allowed value.
ValidationException codes:
Definition at line 45 of file IntegerDef.php.
Referenced by Wikimedia\ParamValidator\TypeDef\IntegerDef\describeSettings(), and Wikimedia\ParamValidator\TypeDef\IntegerDef\validate().