express-validator
Advanced tools
Comparing version 2.20.3 to 2.20.4
## Change Log | ||
### v2.20.4 2016/05/06 | ||
- [54156e1](https://github.com/ctavan/express-validator/commit/54156e14ea2311c27beba0e854c25fe50ee9b22f) Upgrade to 2.20.4 to update validator to v5 (@rustybailey) | ||
- [4fe80ec](https://github.com/ctavan/express-validator/commit/4fe80ec3efedf3feec9412b3a0e57f598ec7be60) Update node-validator to v5 and restore automatic string coercion. (@rustybailey) | ||
- [bfd9502](https://github.com/ctavan/express-validator/commit/bfd9502e9da38ac2dcdc28c720cbf78d4af3c4dd) Update changelog. (@rustybailey) | ||
### v2.20.3 2016/03/21 | ||
- [0fafa68](https://github.com/ctavan/express-validator/commit/0fafa68e0bc21c06a673d6c2ac160ababdccf04c) Upgrade to 2.20.3 (@rustybailey) | ||
- [7884efc](https://github.com/ctavan/express-validator/commit/7884efc891c39d5fd4d1c41fef08f8cb01bf0a39) Convert promises to Bluebird promises in order to use reflect(). Should fix #220 (@rustybailey) | ||
- [659978a](https://github.com/ctavan/express-validator/commit/659978ab0dd38c8eb10b00ea92bcd857a6e5f627) Update changelog (@rustybailey) | ||
### v2.20.2 2016/03/13 | ||
@@ -19,4 +29,6 @@ - [a4a603b](https://github.com/ctavan/express-validator/commit/a4a603bce78f96a4b0987af5cf2490e07cd44404) Upgrade to 2.20.2 (@rustybailey) | ||
- [dca9911](https://github.com/ctavan/express-validator/commit/dca9911928dba20dbd3fa31f39260b7f18da22f0) Apply README fixes from 9b74fb4ffd4edce7268b9d1e9303829cdb8ae14e (@rustybailey) | ||
- [c704a22](https://github.com/ctavan/express-validator/commit/c704a2203f430dacff765e83862e36e1cc45471d) Upgrade to 2.19.2 | ||
- [9b74fb4](https://github.com/ctavan/express-validator/commit/9b74fb4ffd4edce7268b9d1e9303829cdb8ae14e) Fix matches example in README (resolves #209) | ||
### v2.19.2 2016/03/09 | ||
- [c704a22](https://github.com/ctavan/express-validator/commit/c704a2203f430dacff765e83862e36e1cc45471d) Upgrade to 2.19.2 (@rustybailey) | ||
- [9b74fb4](https://github.com/ctavan/express-validator/commit/9b74fb4ffd4edce7268b9d1e9303829cdb8ae14e) Fix matches example in README (resolves #209) (@rustybailey) | ||
- [20f033a](https://github.com/ctavan/express-validator/commit/20f033a9f6a7ba6ad1f3d9eb6c34e8e804071d0a) Added missing require that broke build of tests on node v0.10.43 | ||
@@ -36,3 +48,3 @@ - [981239f](https://github.com/ctavan/express-validator/commit/981239fd7d7841b2c862c28e1d3f92836f52dcaa) Readme and tests updated after review. | ||
### v2.19.0 2016/01/21 | ||
- [479dc71](https://github.com/ctavan/express-validator/commit/479dc71c78e73d0e525b8111c7672c524564b60e) 2.19.0 | ||
- [479dc71](https://github.com/ctavan/express-validator/commit/479dc71c78e73d0e525b8111c7672c524564b60e) 2.19.0 (@rustybailey) | ||
- [460e11c](https://github.com/ctavan/express-validator/commit/460e11c6df1210d66abd96cd3d2593c429528edf) Upgrade dependency (validator.js) from 4.2.x -> 4.5.x (@aristidesfl) | ||
@@ -199,3 +211,3 @@ | ||
- [079c6da](https://github.com/ctavan/express-validator/commit/079c6da0bfe14f95a0b94721488e06081e5b89ed) Update package.json (@gkorland) | ||
- [a91664b](https://github.com/ctavan/express-validator/commit/a91664be05bd3ce37811b0c1e24a75aa8d6e5bff) Update node-validator repository url (@marcbachmann) | ||
- [a91664b](https://github.com/ctavan/express-validator/commit/a91664be05bd3ce37811b0c1e24a75aa8d6e5bff) Update node-validator repository url | ||
- [6fe2aa6](https://github.com/ctavan/express-validator/commit/6fe2aa67a7f9fd0110085e67a8066bc46cdbe605) - fixed typo (@theorm) | ||
@@ -202,0 +214,0 @@ - [816437a](https://github.com/ctavan/express-validator/commit/816437a7df0299172d9e78ad6c3d0f29e07ebff9) - and quoting node versions to make travis linter happy (@theorm) |
@@ -5,2 +5,43 @@ var validator = require('validator'); | ||
// When validator upgraded to v5, they removed automatic string coercion | ||
// The next few methods (up to validator.init()) restores that functionality | ||
// so that express-validator can continue to function normally | ||
validator.extend = function(name, fn) { | ||
validator[name] = function() { | ||
var args = Array.prototype.slice.call(arguments); | ||
args[0] = validator.toString(args[0]); | ||
return fn.apply(validator, args); | ||
}; | ||
}; | ||
validator.init = function() { | ||
for (var name in validator) { | ||
if (typeof validator[name] !== 'function' || name === 'toString' || | ||
name === 'toDate' || name === 'extend' || name === 'init' || | ||
name === 'isServerSide') { | ||
continue; | ||
} | ||
validator.extend(name, validator[name]); | ||
} | ||
}; | ||
validator.toString = function(input) { | ||
if (typeof input === 'object' && input !== null && input.toString) { | ||
input = input.toString(); | ||
} else if (input === null || typeof input === 'undefined' || (isNaN(input) && !input.length)) { | ||
input = ''; | ||
} | ||
return '' + input; | ||
}; | ||
validator.toDate = function(date) { | ||
if (Object.prototype.toString.call(date) === '[object Date]') { | ||
return date; | ||
} | ||
date = Date.parse(date); | ||
return !isNaN(date) ? new Date(date) : null; | ||
}; | ||
validator.init(); | ||
// validators and sanitizers not prefixed with is/to | ||
@@ -7,0 +48,0 @@ var additionalValidators = ['contains', 'equals', 'matches']; |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "2.20.3", | ||
"version": "2.20.4", | ||
"homepage": "https://github.com/ctavan/express-validator", | ||
@@ -34,3 +34,3 @@ "license": "MIT", | ||
"lodash": "4.6.x", | ||
"validator": "4.9.x" | ||
"validator": "5.2.x" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
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
140670
2362
+ Addedvalidator@5.2.0(transitive)
- Removeddepd@1.1.0(transitive)
- Removedvalidator@4.9.0(transitive)
Updatedvalidator@5.2.x