express-validator
Advanced tools
Comparing version 2.10.0 to 2.11.0
## Change Log | ||
### upcoming 2015/05/04 | ||
- [ea00f9d](https://github.com/ctavan/express-validator/commit/ea00f9d6cfe0859f6f00ceb45d66f4d9270064b0) Update changelog. (@rustybailey) | ||
### v2.10.0 2015/05/04 | ||
- [0f48735](https://github.com/ctavan/express-validator/commit/0f48735dc77ec561ad014a721375b561ce3889fe) 2.10.0 (@rustybailey) | ||
- [bc2ef59](https://github.com/ctavan/express-validator/commit/bc2ef59b5a5c45be12f6efb27199a29d8689ac2f) Use the same node versions as node-validator. (@rustybailey) | ||
@@ -5,0 +9,0 @@ - [0c3aaec](https://github.com/ctavan/express-validator/commit/0c3aaecb0f7d4a75a1bc20e94290cfe72e98a49c) Bump validator version to 3.39.0 (@rustybailey) |
@@ -31,2 +31,3 @@ /* | ||
_options.customValidators = options.customValidators || {}; | ||
_options.customSanitizers = options.customSanitizers || {}; | ||
@@ -57,3 +58,10 @@ _options.errorFormatter = options.errorFormatter || function(param, msg, value) { | ||
}); | ||
Object.keys(_options.customSanitizers).forEach(function(customName) { | ||
methods[customName] = function() { | ||
var args = [value].concat(Array.prototype.slice.call(arguments)); | ||
var result = _options.customSanitizers[customName].apply(null, args); | ||
request.updateParam(param, result); | ||
return result; | ||
}; | ||
}); | ||
return methods; | ||
@@ -60,0 +68,0 @@ }; |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"homepage": "https://github.com/ctavan/express-validator", | ||
@@ -15,0 +15,0 @@ "license": "MIT", |
@@ -127,3 +127,24 @@ # express-validator | ||
``` | ||
####`customSanitizers` | ||
_{ "sanitizerName": function(value, [additional arguments]), ... }_ | ||
The `customSanitizers` option can be used to add additional sanitizers methods as needed. This option should be an `Object` defining the sanitizer names and associated functions. | ||
Define your custom sanitizers: | ||
```javascript | ||
app.use(expressValidator({ | ||
customSanitizers: { | ||
toSanitizeSomehow: function(value) { | ||
var newValue = value;//some operations | ||
return newValue; | ||
}, | ||
} | ||
})); | ||
``` | ||
Use them with their sanitizer name: | ||
```javascript | ||
req.sanitizer('address').toSanitizeSomehow(); | ||
``` | ||
### Validation errors | ||
@@ -130,0 +151,0 @@ |
@@ -18,2 +18,7 @@ // Sample app | ||
} | ||
}, | ||
customSanitizers: { | ||
toTestSanitize: function(value) { | ||
return "!!!!"; | ||
} | ||
} | ||
@@ -20,0 +25,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
68436
21
887
264
0