MediaWiki REL1_34
|
Type definition for a floating-point type. More...
Public Member Functions | |
stringifyValue ( $name, $value, array $settings, array $options) | |
Convert a value to a string representation. | |
validate ( $name, $value, array $settings, array $options) | |
Validate the value. | |
Public Member Functions inherited from Wikimedia\ParamValidator\TypeDef | |
__construct (Callbacks $callbacks) | |
describeSettings ( $name, array $settings, array $options) | |
"Describe" a settings array | |
getEnumValues ( $name, array $settings, array $options) | |
Get the values for enum-like parameters. | |
getValue ( $name, array $settings, array $options) | |
Get the value from the request. | |
normalizeSettings (array $settings) | |
Normalize a settings array. | |
Private Member Functions | |
fixLocaleWeirdness ( $value) | |
Attempt to fix locale weirdness. | |
Additional Inherited Members | |
Protected Attributes inherited from Wikimedia\ParamValidator\TypeDef | |
Callbacks | $callbacks |
Type definition for a floating-point type.
A valid representation consists of:
+
or -
).
as the decimal separator and no groupingThus, for example, "12", "-.4", "6.022e23", or "+1.7e-10".
The result from validate() is a PHP float.
ValidationException codes:
Definition at line 29 of file FloatDef.php.
|
private |
Attempt to fix locale weirdness.
We don't have any usable number formatting function that's not locale-aware, and setlocale()
isn't safe in multithreaded environments. Sigh.
string | $value | Value to fix |
Definition at line 54 of file FloatDef.php.
Referenced by Wikimedia\ParamValidator\TypeDef\FloatDef\stringifyValue().
Wikimedia\ParamValidator\TypeDef\FloatDef::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 67 of file FloatDef.php.
References Wikimedia\ParamValidator\TypeDef\FloatDef\fixLocaleWeirdness().
Wikimedia\ParamValidator\TypeDef\FloatDef::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 31 of file FloatDef.php.