express-json-validator-middleware
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "express-json-validator-middleware", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "An Express middleware to validate requests against JSON Schemas", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -46,5 +46,5 @@ # express-json-validator-middleware | ||
3. *Optional* - Define a shortcut function. This is not needed, and it is perfectly okay to use validator.validate() | ||
3. *Optional* - Define a shortcut function. Bind is necessary here in order to pass ```this``` correctly | ||
```js | ||
var validate = validator.validate; | ||
var validate = validator.validate.bind(validator); | ||
``` | ||
@@ -98,3 +98,3 @@ | ||
// Define a shortcut. It is perfectly okay ot use validator.validate() | ||
var validate = validator.validate; | ||
var validate = validator.validate.bind(validator); | ||
@@ -101,0 +101,0 @@ // Define a JSON Schema |
@@ -14,3 +14,3 @@ var Ajv = require('ajv'); | ||
validate(options) { | ||
var that = this; | ||
var self = this; | ||
return function (req, res, next) { | ||
@@ -21,3 +21,3 @@ var validationErrors = {}; | ||
let schema = options[requestProperty]; | ||
let validateFunction = that.ajv.compile(schema); | ||
let validateFunction = this.ajv.compile(schema); | ||
@@ -29,3 +29,3 @@ var valid = validateFunction(req[requestProperty]); | ||
} | ||
}); | ||
}, self); | ||
@@ -32,0 +32,0 @@ if (Object.keys(validationErrors).length != 0) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14537