wiki.techinc.nl/includes/Rest/Validator/BodyValidator.php
Brad Jorsch ebfbd2d42a rest: Use ParamValidator library, add BodyValidator
Parameter validation is based on parameter definitions like those in the
Action API, using the new ParamValidator library. Handlers should use
the provided Handler methods to access parameters rather than fetching
them directly from the RequestInterface.

Body validation allows the handler to have the (non-form-data) body of a
request parsed and validated. The only validator included in this patch
ignores the body entirely; future patches may implement validation for
JSON bodies based on JSON schemas, or the like.

Bug: T223239
Change-Id: I3c37ea2b432840514b6bff90007c8403989225d5
2019-09-04 10:12:35 -04:00

26 lines
629 B
PHP

<?php
namespace MediaWiki\Rest\Validator;
use MediaWiki\Rest\HttpException;
use MediaWiki\Rest\RequestInterface;
/**
* Interface for validating a request body
*/
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 );
}