wiki.techinc.nl/includes/Rest/Validator/BodyValidator.php
Gergő Tisza c9371c5671
Improve REST API validation documentation
Make it clearer that the 'post' mode of ParamValidator only
applies to application/x-www-form-urlencoded or multipart/form-data
requests, and point to the equivalent mechanism for other request
types. Since developers coming from the action API are already
familiar with ParamValidator, this hopefully makes the other
validation mechanism easier to discover.

Change-Id: Iaa352a2d7e1d52a881b2cd960e34ebb0507ce83c
2020-12-26 13:30:28 -08:00

29 lines
708 B
PHP

<?php
namespace MediaWiki\Rest\Validator;
use MediaWiki\Rest\HttpException;
use MediaWiki\Rest\RequestInterface;
/**
* Interface for validating a request body
*
* @stable to implement
* @see \MediaWiki\Rest\Handler::getBodyValidator()
*/
interface BodyValidator {
/**
* 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().
*
* @param RequestInterface $request
* @return mixed
* @throws HttpException on validation failure
*/
public function validateBody( RequestInterface $request );
}