Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-validator

Package Overview
Dependencies
Maintainers
2
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-validator - npm Package Compare versions

Comparing version 2.10.0 to 2.11.0

test/customSanitizersTest.js

4

CHANGELOG.md
## 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 @@ };

2

package.json

@@ -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 @@ }));

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