Socket
Socket
Sign inDemoInstall

express-json-validator-middleware

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-json-validator-middleware - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "express-json-validator-middleware",
"version": "1.0.0",
"version": "1.0.1",
"description": "An Express middleware to validate requests against JSON Schemas",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -149,5 +149,33 @@ # express-json-validator-middleware

## Custom keywords
Ajv supports custom keywords out of the box. They must be defined only after you initialize a Validator, but before you any validate() middleware. Example:
```js
var { Validator, ValidationError } = require('express-json-validator-middleware');
var validator = new Validator({allErrors: true});
validator.ajv.addKeyword('constant', { validate: function (schema, data) {
return typeof schema == 'object' && schema !== null
? deepEqual(schema, data)
: schema === data;
}, errors: false });
```
More info on custom keywords: [ajv#customs-keywords](https://github.com/epoberezkin/ajv/blob/master/CUSTOM.md#defining-custom-keywords)
## Ajv instance
The Ajv instance can be accessed via validator.ajv.
```js
var { Validator, ValidationError } = require('express-json-validator-middleware');
var validator = new Validator({allErrors: true});
validator.ajv // ajv instance
```
## Tests
```js
```
npm install
npm test

@@ -160,3 +188,3 @@ ```

- [scpacetelescope's understanding json schema](http://spacetelescope.github.io/understanding-json-schema/)
- [spacetelescope's understanding json schema](http://spacetelescope.github.io/understanding-json-schema/)

@@ -163,0 +191,0 @@ ## Notes

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc