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

express-validator

Package Overview
Dependencies
Maintainers
1
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 0.2.1 to 0.2.2

24

lib/express_validator.js

@@ -51,7 +51,15 @@ /*

var value;
// get value and param name for nested inputs like foo[bar][baz]
if (Array.isArray(param)) {
param.map(function(item) {
if(value === undefined) {
// If param is not an array, then split by dot notation
// returning an array. It will return an array even if
// param doesn't have the dot notation.
// 'blogpost' = ['blogpost']
// 'login.username' = ['login', 'username']
if (!Array.isArray(param)) {
param = param.split('.').filter(function(e){return e != '';});
}
// Extract value from params
param.map(function(item) {
if (value === undefined) {
value = req.param(item);

@@ -61,7 +69,4 @@ } else {

}
});
param = param.join('_');
} else {
value = this.param(param);
}
});
param = param.join('.');

@@ -128,2 +133,3 @@ validator.error = function(msg) {

req.assert = req.check;
req.validate = req.check;

@@ -130,0 +136,0 @@ return next();

@@ -9,3 +9,3 @@ {

],
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/ctavan/express-validator",

@@ -24,8 +24,8 @@ "repository": {

"dependencies": {
"validator": "~0.4.5"
"validator": "~0.4.10"
},
"devDependencies": {
"async": "~0.1.18",
"express": "~2.5.9",
"request": "~2.9.153"
"async": "~0.1.22",
"express": "~2.5.11",
"request": "~2.10.0"
},

@@ -32,0 +32,0 @@ "keywords": [

@@ -147,5 +147,19 @@ # express-validator

Alternatively you can use dot-notation to specify nested fields to be checked:
```javascript
req.assert(['user', 'fields', 'email'], 'valid email required').isEmail();
```
## Changelog
### v0.2.2
- Add dot-notation for nested input
- Add validate() alias for check()
### v0.2.1
- Fix chaining validators (@rapee)
### v0.2.0

@@ -152,0 +166,0 @@ - Added `validationErrors()` method (by @orfaust)

@@ -14,2 +14,3 @@ var assert = require('assert');

req.assert(['user', 'fields', 'email'], 'not empty').notEmpty();
req.assert('user.fields.email', 'not empty').notEmpty();
req.assert(['user', 'fields', 'email'], 'valid email required').isEmail();

@@ -29,3 +30,4 @@

assert.deepEqual(body[0].msg, 'not empty');
assert.deepEqual(body[1].msg, 'valid email required');
assert.deepEqual(body[1].msg, 'not empty');
assert.deepEqual(body[2].msg, 'valid email required');
}

@@ -32,0 +34,0 @@ function pass(body) {

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