Core
Write Plugins v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

validation #

Accessor to the data validation API


addType #

Adds a new data type, to be used for document validation.

Arguments #

addType(Type);

ArgumentsTypeDescription
Type
object
A class implementing the abstract BaseValidationType class

validate #

Validates the content of a request body (mutates the request).

Arguments #

validate(request, [verbose]);

ArgumentsTypeDescription
requestRequestRequest object with a non-empty body content
verbose
boolean
If true, returns an exhaustive validation report, instead of failing at the first error encountered

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 error encountered
  • true: the promise is resolved even if the validation fails. The promise resolves a validation status report, containing the following properties:
    • validation: {boolean} validation state
    • errorMessages: {array} the exhaustive list of encountered errors