validate #
Validates the content of a request body (mutates the request).
Arguments #
validate(request: KuzzleRequest, verbose: boolean): Promise<any>;
Arguments | Type | Description |
---|---|---|
request | KuzzleRequest | KuzzleRequest object with a non-empty body content |
verbose | boolean | If true, returns an exhaustive validation report, instead of failing at the first encountered error |
Return #
The validate
function returns a promise, and if relevant, default values are applied to the provided request.
If a validation error occurs, the behavior depends on the validation
optional parameter:
false
(default): the promise is rejected with the first encountered errortrue
: the promise is resolved even if the validation fails. The promise resolves a validation status report, containing the following properties:validation
: {boolean} validation stateerrorMessages
: {array} the exhaustive list of encountered errors
Edit this page on Github (opens new window)