MediaWiki
1.34.0
|
Type definition for timestamp types. More...
Public Member Functions | |
__construct (Callbacks $callbacks, array $options=[]) | |
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... | |
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... | |
normalizeSettings (array $settings) | |
Normalize a settings array. More... | |
Public Attributes | |
const | PARAM_TIMESTAMP_FORMAT = 'param-timestamp-format' |
(string|int) Timestamp format to return from validate() More... | |
Protected Attributes | |
string int | $defaultFormat |
int | $stringifyFormat |
Protected Attributes inherited from Wikimedia\ParamValidator\TypeDef | |
Callbacks | $callbacks |
Type definition for timestamp types.
This uses the wikimedia/timestamp library for parsing and formatting the timestamps.
The result from validate() is a ConvertibleTimestamp by default, but this may be changed by both a constructor option and a PARAM constant.
ValidationException codes:
Definition at line 29 of file TimestampDef.php.
Wikimedia\ParamValidator\TypeDef\TimestampDef::__construct | ( | Callbacks | $callbacks, |
array | $options = [] |
||
) |
Callbacks | $callbacks | |
array | $options | Options:
|
Definition at line 57 of file TimestampDef.php.
References Wikimedia\ParamValidator\TypeDef\$callbacks.
Wikimedia\ParamValidator\TypeDef\TimestampDef::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 94 of file TimestampDef.php.
Wikimedia\ParamValidator\TypeDef\TimestampDef::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 64 of file TimestampDef.php.
References Wikimedia\ParamValidator\TypeDef\TimestampDef\$defaultFormat, and Wikimedia\ParamValidator\TypeDef\TimestampDef\PARAM_TIMESTAMP_FORMAT.
|
protected |
Definition at line 44 of file TimestampDef.php.
Referenced by Wikimedia\ParamValidator\TypeDef\TimestampDef\validate().
|
protected |
Definition at line 47 of file TimestampDef.php.
const Wikimedia\ParamValidator\TypeDef\TimestampDef::PARAM_TIMESTAMP_FORMAT = 'param-timestamp-format' |
(string|int) Timestamp format to return from validate()
Values include:
This does not affect the format returned by stringifyValue().
Definition at line 41 of file TimestampDef.php.
Referenced by Wikimedia\ParamValidator\TypeDef\TimestampDef\validate().