MediaWiki master
MediaWiki\Api\Validator\ApiParamValidator Class Reference

This wraps a bunch of the API-specific parameter validation logic. More...

Public Member Functions

 __construct (ApiMain $main, ObjectFactory $objectFactory)
 
 checkSettings (ApiBase $module, array $params, string $name, array $options)
 Check settings for the Action API.
 
 getHelpInfo (ApiBase $module, string $name, $settings, array $options)
 Describe parameter settings in human-readable format.
 
 getParamInfo (ApiBase $module, string $name, $settings, array $options)
 Describe parameter settings in a machine-readable format.
 
 getValue (ApiBase $module, string $name, $settings, array $options=[])
 Get and validate a value.
 
 knownTypes ()
 List known type names.
 
 normalizeSettings ( $settings)
 Adjust certain settings where ParamValidator differs from historical Action API behavior.
 
 validateValue (ApiBase $module, string $name, $value, $settings, array $options=[])
 Validate a parameter value using a settings array.
 

Detailed Description

This wraps a bunch of the API-specific parameter validation logic.

It's intended to be used in ApiMain by composition.

Since
1.35

Definition at line 38 of file ApiParamValidator.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Api\Validator\ApiParamValidator::__construct ( ApiMain  $main,
ObjectFactory  $objectFactory 
)
Access: internal
Parameters
ApiMain$main
ObjectFactory$objectFactory

Definition at line 96 of file ApiParamValidator.php.

Member Function Documentation

◆ checkSettings()

MediaWiki\Api\Validator\ApiParamValidator::checkSettings ( ApiBase  $module,
array  $params,
string  $name,
array  $options 
)

Check settings for the Action API.

Parameters
ApiBase$module
array$paramsAll module params to test
string$nameParameter to test
array$optionsOptions array
Returns
array As for ParamValidator::checkSettings()

Definition at line 190 of file ApiParamValidator.php.

◆ getHelpInfo()

MediaWiki\Api\Validator\ApiParamValidator::getHelpInfo ( ApiBase  $module,
string  $name,
  $settings,
array  $options 
)

Describe parameter settings in human-readable format.

Parameters
ApiBase$module
string$nameParameter name being described.
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array.
Returns
Message[]

Definition at line 428 of file ApiParamValidator.php.

◆ getParamInfo()

MediaWiki\Api\Validator\ApiParamValidator::getParamInfo ( ApiBase  $module,
string  $name,
  $settings,
array  $options 
)

Describe parameter settings in a machine-readable format.

Parameters
ApiBase$module
string$nameParameter name.
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array.
Returns
array

Definition at line 412 of file ApiParamValidator.php.

◆ getValue()

MediaWiki\Api\Validator\ApiParamValidator::getValue ( ApiBase  $module,
string  $name,
  $settings,
array  $options = [] 
)

Get and validate a value.

Parameters
ApiBase$module
string$nameParameter name, unprefixed
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array
Returns
mixed Validated parameter value
Exceptions
ApiUsageExceptionif the value is invalid

Definition at line 366 of file ApiParamValidator.php.

References ApiBase\encodeParamName().

◆ knownTypes()

MediaWiki\Api\Validator\ApiParamValidator::knownTypes ( )

List known type names.

Returns
string[]

Definition at line 112 of file ApiParamValidator.php.

◆ normalizeSettings()

MediaWiki\Api\Validator\ApiParamValidator::normalizeSettings (   $settings)

Adjust certain settings where ParamValidator differs from historical Action API behavior.

Parameters
array | mixed$settings
Returns
array

Definition at line 150 of file ApiParamValidator.php.

◆ validateValue()

MediaWiki\Api\Validator\ApiParamValidator::validateValue ( ApiBase  $module,
string  $name,
  $value,
  $settings,
array  $options = [] 
)

Validate a parameter value using a settings array.

Parameters
ApiBase$module
string$nameParameter name, unprefixed
mixed$valueParameter value
array | mixed$settingsDefault value or an array of settings using PARAM_* constants.
array$optionsOptions array
Returns
mixed Validated parameter value(s)
Exceptions
ApiUsageExceptionif the value is invalid

Definition at line 389 of file ApiParamValidator.php.

References ApiBase\encodeParamName().


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