Skip to content

validate

validate: (options?, schema?) => any

Defined in: lib/json-api-query/validate.js:43

Creates a compiled JSON API query validator.

Any AJV option.

string | boolean = 'array'

Coerce validated values to specified types.

boolean = true

Restrict validation to own properties of data object.

object = defaultSchema

JSON Schema 2020-12. Defaults to the included schema.

any

const validator = validate();
const valid = validator(queryParams); // where queryParams is an object
if (!valid) {
console.log(validator.errors);
}