express-validator
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"homepage": "https://github.com/ctavan/express-validator", | ||
@@ -12,0 +12,0 @@ "license": "MIT", |
33
tst.js
@@ -1,2 +0,2 @@ | ||
const { checkSchema, validationResult } = require('./check'); | ||
const { check, checkSchema, validationResult } = require('./check'); | ||
@@ -6,14 +6,21 @@ const express = require('express'); | ||
app.use(express.json()); | ||
app.post('/*', checkSchema({ | ||
foo: { | ||
in: ['body'], | ||
exists: { | ||
errorMessage: 'bla' | ||
}, | ||
custom: { | ||
options: value => (value || '').startsWith('foo') | ||
} | ||
} | ||
}), (req, res) => { | ||
console.log(req.body); | ||
app.post('/*', [ | ||
check('password') | ||
// .isLength({min: 6}) | ||
// .withMessage("Minimum Length must be at least 6") | ||
// .optional({ checkFalsy: true }) | ||
// .custom(() => true) | ||
, | ||
check('passwordConfirmation').custom((value, { req }) => { | ||
if(req.body.password === value) | ||
return true; | ||
else | ||
throw new Error("Password Doesn't match"); | ||
}) | ||
], (req, res) => { | ||
console.log('body', req.body); | ||
console.log('query', req.query); | ||
console.log('headers', req.headers); | ||
console.log('params', req.params); | ||
console.log('cookies', req.cookies); | ||
res.json(validationResult(req).array()); | ||
@@ -20,0 +27,0 @@ }); |
@@ -5,5 +5,8 @@ const _ = require('lodash'); | ||
module.exports = (req, context) => { | ||
selectFields(req, context).forEach(instance => { | ||
selectFields(req, context).filter(instance => { | ||
const initialValue = _.get(req[instance.location], instance.path); | ||
return initialValue !== instance.value; | ||
}).forEach(instance => { | ||
_.set(req[instance.location], instance.path, instance.value); | ||
}); | ||
}; |
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
80082
1390