express-validator
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -45,3 +45,3 @@ /* | ||
Object.keys(validator).forEach(function(methodName) { | ||
if (methodName.match(/^to/) || methodName in sanitizers) { | ||
if (methodName.match(/^to/) || sanitizers.indexOf(methodName) !== -1) { | ||
methods[methodName] = function() { | ||
@@ -106,3 +106,3 @@ var arguments = Array.prototype.slice.call(arguments); | ||
Object.keys(validator).forEach(function(methodName) { | ||
if (!methodName.match(/^to/) && !(methodName in sanitizers)) { | ||
if (!methodName.match(/^to/) && sanitizers.indexOf(methodName) === -1) { | ||
methods[methodName] = function() { | ||
@@ -109,0 +109,0 @@ var arguments = Array.prototype.slice.call(arguments); |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"homepage": "https://github.com/ctavan/express-validator", | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -195,28 +195,10 @@ # express-validator | ||
You can extend the `Validator` and `Filter` objects to add custom validation | ||
and sanitization method. | ||
You can add your own validators using `expressValidator.validator.extend(name, fn)` | ||
Custom validation which always fails. Useful for debugging or for | ||
adding messages manually when doing complex validation: | ||
```javascript | ||
var expressValidator = require('express-validator'); | ||
expressValidator.Validator.prototype.fail = function() { | ||
//You could validate against this.str, instead of just erroring out. | ||
this.error(this.msg); | ||
return this; | ||
}; | ||
expressValidator.validator.extend('isFinite', function (str) { | ||
return isFinite(str); | ||
}); | ||
``` | ||
Custom sanitization which lower-cases the string: | ||
```javascript | ||
expressValidator.Filter.prototype.toLowerCase = function(){ | ||
this.modify(this.str.toLowerCase()); | ||
return this.str; | ||
}; | ||
``` | ||
## Changelog | ||
@@ -223,0 +205,0 @@ |
Sorry, the diff of this file is not supported yet
28193
257