MediaWiki master
MediaWiki\ParamValidator\TypeDef\ArrayDef Class Reference

Type definition for array structures, typically used for validating JSON request bodies. More...

Inherits Wikimedia\ParamValidator\TypeDef.

Collaboration diagram for MediaWiki\ParamValidator\TypeDef\ArrayDef:

Public Member Functions

 supportsArrays ()
 Whether the value may be an array.
 
 validate ( $name, $value, array $settings, array $options)
 Validate the value.
 
- Public Member Functions inherited from Wikimedia\ParamValidator\TypeDef
 __construct (Callbacks $callbacks)
 
 checkSettings (string $name, $settings, array $options, array $ret)
 Validate a parameter settings array.
 
 getEnumValues ( $name, array $settings, array $options)
 Get the values for enum-like parameters.
 
 getHelpInfo ( $name, array $settings, array $options)
 Describe parameter settings in human-readable format.
 
 getParamInfo ( $name, array $settings, array $options)
 Describe parameter settings in a machine-readable format.
 
 getValue ( $name, array $settings, array $options)
 Get the value from the request.
 
 normalizeSettings (array $settings)
 Normalize a settings array.
 
 stringifyValue ( $name, $value, array $settings, array $options)
 Convert a value to a string representation.
 

Additional Inherited Members

- Protected Member Functions inherited from Wikimedia\ParamValidator\TypeDef
 failure ( $failure, $name, $value, array $settings, array $options, $fatal=true)
 Record a failure message.
 
 failureMessage ( $code, array $data=null, $suffix=null)
 Create a DataMessageValue representing a failure.
 
- Protected Attributes inherited from Wikimedia\ParamValidator\TypeDef
Callbacks $callbacks
 

Detailed Description

Type definition for array structures, typically used for validating JSON request bodies.

Failure codes:

  • 'notarray': The value is not an array.
Todo
implement validation based on a JSON schema
Since
1.42

Definition at line 18 of file ArrayDef.php.

Member Function Documentation

◆ supportsArrays()

MediaWiki\ParamValidator\TypeDef\ArrayDef::supportsArrays ( )

Whether the value may be an array.

Note that this is different from multi-value. This should only return true if each value can be an array.

Since
1.41
Stability: stable
to override
Returns
bool

Reimplemented from Wikimedia\ParamValidator\TypeDef.

Definition at line 20 of file ArrayDef.php.

◆ validate()

MediaWiki\ParamValidator\TypeDef\ArrayDef::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.

Parameters
string$nameParameter name being validated.
mixed$valueValue to validate, from getValue().
array$settingsParameter settings array.
array$optionsOptions array. Note the following values that may be set by ParamValidator:
  • is-default: (bool) If present and true, the value was taken from PARAM_DEFAULT rather that being supplied by the client.
  • values-list: (string[]) If defined, values of a multi-valued parameter are being processed (and this array holds the full set of values).
Returns
mixed Validated value
Exceptions
ValidationExceptionif the value is invalid

Reimplemented from Wikimedia\ParamValidator\TypeDef.

Definition at line 24 of file ArrayDef.php.

References Wikimedia\ParamValidator\TypeDef\failure().


The documentation for this class was generated from the following file: