architect-ajv-middleware
v1.1.0
Published
architect plugin to provide and configure ajv connect middleware.
Downloads
228
Readme
architect-ajv-middleware
This architect plugin register a middleware to check that the request data matches an AJV schema.
The json schema must be specified in the route spec in the validation
attribute:
rest.get({
url: '/',
validation: ajvSchema
},
(req, res) => {
// ...
});
The $id
or title
attribute on the json schema must be set to enable ajv validator cache.
Installation
npm install --save architect-ajv-middleware
Config Format
{
"packagePath": "architect-ajv-middleware",
"ajv": {
allErrors: true,
coerceTypes: true,
useDefaults: true,
removeAdditional: true
},
"http": {
statusCode: 422,
code: 'UnprocessableEntity'
}
}