Write Plugins v1.x

# validation

Accessor to the data validation API

# addType

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

# Arguments

Copied to clipboard!

Arguments Type Description
A class implementing the abstract BaseValidationType class

# validate

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

# Arguments

Copied to clipboard!
validate(request, [verbose]);

Arguments Type Description
request Request Request object with a non-empty body content
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