MediaWiki REL1_39
MediaWiki\Rest\Validator\Validator Class Reference

Wrapper for ParamValidator. More...

Public Member Functions

 __construct (ObjectFactory $objectFactory, RequestInterface $request, Authority $authority)
 
 validateBody (RequestInterface $request, Handler $handler)
 Validate the body of a request.
 
 validateParams (array $paramSettings)
 Validate parameters.
 

Detailed Description

Wrapper for ParamValidator.

It's intended to be used in the REST API classes by composition.

Since
1.34

Definition at line 32 of file Validator.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\Validator\Validator::__construct ( ObjectFactory $objectFactory,
RequestInterface $request,
Authority $authority )
Parameters
ObjectFactory$objectFactory
RequestInterface$request
Authority$authority
Access: internal

Definition at line 87 of file Validator.php.

Member Function Documentation

◆ validateBody()

MediaWiki\Rest\Validator\Validator::validateBody ( RequestInterface $request,
Handler $handler )

Validate the body of a request.

This may return a data structure representing the parsed body. When used in the context of Handler::validateParams(), the returned value will be available to the handler via Handler::getValidatedBody().

Parameters
RequestInterface$request
Handler$handlerUsed to call getBodyValidator()
Returns
mixed May be null
Exceptions
HttpExceptionon validation failure

Definition at line 139 of file Validator.php.

References MediaWiki\Rest\RequestInterface\getBody(), MediaWiki\Rest\Handler\getBodyValidator(), MediaWiki\Rest\RequestInterface\getHeaderLine(), and MediaWiki\Rest\RequestInterface\getMethod().

Referenced by MediaWiki\Rest\Handler\validate().

◆ validateParams()

MediaWiki\Rest\Validator\Validator::validateParams ( array $paramSettings)

Validate parameters.

Parameters
array[]$paramSettingsParameter settings
Returns
array Validated parameters
Exceptions
HttpExceptionon validation failure

Definition at line 107 of file Validator.php.

References Wikimedia\ParamValidator\ValidationException\getFailureMessage(), Wikimedia\ParamValidator\ValidationException\getParamName(), Wikimedia\ParamValidator\ValidationException\getParamValue(), and MediaWiki\Rest\Handler\PARAM_SOURCE.

Referenced by MediaWiki\Rest\Handler\validate().


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