validate
validate: (
options?,schema?) =>any
Defined in: lib/json-api-query/validate.js:43
Creates a compiled JSON API query validator.
Parameters
Section titled “Parameters”options?
Section titled “options?”Any AJV option.
coerceTypes?
Section titled “coerceTypes?”string | boolean = 'array'
Coerce validated values to specified types.
ownProperties?
Section titled “ownProperties?”boolean = true
Restrict validation to own properties of data object.
schema?
Section titled “schema?”object = defaultSchema
JSON Schema 2020-12. Defaults to the included schema.
Returns
Section titled “Returns”any
Example
Section titled “Example”const validator = validate();const valid = validator(queryParams); // where queryParams is an object
if (!valid) { console.log(validator.errors);}