express-validator
Advanced tools
Comparing version 5.3.0 to 5.3.1
@@ -48,3 +48,3 @@ import * as express from 'express'; | ||
isISBN(version?: number): this; | ||
isISSN(options?: ValidatorOptions.IsISSNOptions): this | ||
isISSN(options?: ValidatorOptions.IsISSNOptions): this; | ||
isJSON(): this; | ||
@@ -244,2 +244,2 @@ isLatLong(): this; | ||
} | ||
} | ||
} |
@@ -10,3 +10,3 @@ --- | ||
- `field` *(optional)*: a string or an array of strings of field names to validate against. | ||
- `message` *(optional)*: an error message to use when failed validators don't specify a message. Defaults to `Invalid value`; see also [Dynamic Messages](feature-dynamic-messages.md). | ||
- `message` *(optional)*: an error message to use when failed validators don't specify a message. Defaults to `Invalid value`; see also [Dynamic Messages](feature-error-messages.md#dynamic-messages). | ||
> *Returns:* a [Validation Chain](api-validation-chain.md) | ||
@@ -117,2 +117,2 @@ | ||
], productUpdateHandler) | ||
``` | ||
``` |
@@ -71,3 +71,3 @@ --- | ||
check('password', 'The password must be 5+ chars long and contain a number') | ||
.not().in(['123', 'password', 'god']).withMessage('Do not use a common word as the password') | ||
.not().isIn(['123', 'password', 'god']).withMessage('Do not use a common word as the password') | ||
.isLength({ min: 5 }) | ||
@@ -102,2 +102,2 @@ .matches(/\d/) | ||
}); | ||
``` | ||
``` |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "5.3.0", | ||
"version": "5.3.1", | ||
"homepage": "https://express-validator.github.io", | ||
@@ -40,6 +40,6 @@ "license": "MIT", | ||
"coveralls": "^3.0.0", | ||
"docusaurus": "^1.3.0", | ||
"docusaurus": "^1.5.1", | ||
"eslint": "^4.19.1", | ||
"mocha": "^5.1.1", | ||
"nyc": "^11.7.1", | ||
"nyc": "^13.0.1", | ||
"typescript": "^2.8.3" | ||
@@ -46,0 +46,0 @@ }, |
62
tst.js
const expressValidator = require('./'); | ||
const { body, checkSchema, oneOf, validationResult } = require('./check'); | ||
const { check, checkSchema, oneOf, validationResult } = require('./check'); | ||
const { matchedData } = require('./filter'); | ||
@@ -10,36 +10,36 @@ const express = require('express'); | ||
app.use(bodyParser.text()); | ||
// app.use([ | ||
// body('id') | ||
// // .customSanitizer(value => { | ||
// // console.log(value); | ||
// // return value._id; | ||
// // }) | ||
// .toInt(), | ||
// ], (req, res) => { | ||
// const data = matchedData(req, { onlyValidData: false }); | ||
// const result = validationResult(req); | ||
app.all('/*', [ | ||
check('id').escape() | ||
], (req, res) => { | ||
const data = matchedData(req, { onlyValidData: false }); | ||
const result = validationResult(req); | ||
// res.json({ | ||
// data, | ||
// errors: result.array() | ||
res.json({ | ||
data, | ||
errors: result.array() | ||
}); | ||
}); | ||
// app.use(expressValidator()); | ||
// app.use((req, res) => { | ||
// req.checkBody('id').custom(value => { | ||
// return new Promise(resolve => { | ||
// setTimeout(() => { | ||
// resolve(); | ||
// }, 3000); | ||
// }); | ||
// }); | ||
// req.checkBody({ | ||
// id: { | ||
// notEmpty: { errorMessage: 'not empty' } | ||
// } | ||
// }); | ||
// req.getValidationResult().then(result => { | ||
// res.json({ | ||
// errors: result.mapped() | ||
// }); | ||
// }); | ||
// }); | ||
app.use(expressValidator()); | ||
app.use((req, res) => { | ||
req.checkBody('id').custom(value => { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 3000); | ||
}); | ||
}); | ||
req.getValidationResult().then(result => { | ||
res.json({ | ||
errors: result.mapped() | ||
}); | ||
}); | ||
}); | ||
app.listen(3001); |
@@ -7,20 +7,101 @@ { | ||
"tagline": "express-validator docs", | ||
"check-api": "check API", | ||
"filter-api": "filter API", | ||
"legacy-api": "Legacy API", | ||
"sanitization-chain-api": "Sanitization Chain API", | ||
"validation-chain-api": "Validation Chain API", | ||
"validation-result-api": "Validation Result API", | ||
"custom-validators-sanitizers": "Custom validators/sanitizers", | ||
"custom-error-messages": "Custom Error Messages", | ||
"sanitization": "Sanitization", | ||
"schema-validation": "Schema Validation", | ||
"whole-body-validation": "Whole Body Validation", | ||
"wildcards": "Wildcards", | ||
"index": "Getting Started", | ||
"Docs": "Docs", | ||
"API": "API", | ||
"GitHub": "GitHub", | ||
"Introduction": "Introduction", | ||
"Features": "Features" | ||
"docs": { | ||
"check-api": { | ||
"title": "check API" | ||
}, | ||
"filter-api": { | ||
"title": "filter API" | ||
}, | ||
"legacy-api": { | ||
"title": "Legacy API" | ||
}, | ||
"sanitization-chain-api": { | ||
"title": "Sanitization Chain API" | ||
}, | ||
"validation-chain-api": { | ||
"title": "Validation Chain API" | ||
}, | ||
"validation-result-api": { | ||
"title": "Validation Result API" | ||
}, | ||
"custom-validators-sanitizers": { | ||
"title": "Custom validators/sanitizers" | ||
}, | ||
"custom-error-messages": { | ||
"title": "Custom Error Messages" | ||
}, | ||
"sanitization": { | ||
"title": "Sanitization" | ||
}, | ||
"schema-validation": { | ||
"title": "Schema Validation" | ||
}, | ||
"whole-body-validation": { | ||
"title": "Whole Body Validation" | ||
}, | ||
"wildcards": { | ||
"title": "Wildcards" | ||
}, | ||
"index": { | ||
"title": "Getting Started" | ||
}, | ||
"version-5.2.0-check-api": { | ||
"title": "check API" | ||
}, | ||
"version-5.2.0-filter-api": { | ||
"title": "filter API" | ||
}, | ||
"version-5.2.0-legacy-api": { | ||
"title": "Legacy API" | ||
}, | ||
"version-5.2.0-sanitization-chain-api": { | ||
"title": "Sanitization Chain API" | ||
}, | ||
"version-5.2.0-validation-chain-api": { | ||
"title": "Validation Chain API" | ||
}, | ||
"version-5.2.0-validation-result-api": { | ||
"title": "Validation Result API" | ||
}, | ||
"version-5.2.0-custom-validators-sanitizers": { | ||
"title": "Custom validators/sanitizers" | ||
}, | ||
"version-5.2.0-custom-error-messages": { | ||
"title": "Custom Error Messages" | ||
}, | ||
"version-5.2.0-sanitization": { | ||
"title": "Sanitization" | ||
}, | ||
"version-5.2.0-schema-validation": { | ||
"title": "Schema Validation" | ||
}, | ||
"version-5.2.0-whole-body-validation": { | ||
"title": "Whole Body Validation" | ||
}, | ||
"version-5.2.0-wildcards": { | ||
"title": "Wildcards" | ||
}, | ||
"version-5.2.0-index": { | ||
"title": "Getting Started" | ||
}, | ||
"version-5.3.0-filter-api": { | ||
"title": "filter API" | ||
}, | ||
"version-5.3.0-validation-chain-api": { | ||
"title": "Validation Chain API" | ||
}, | ||
"version-5.3.0-custom-validators-sanitizers": { | ||
"title": "Custom validators/sanitizers" | ||
} | ||
}, | ||
"links": { | ||
"Docs": "Docs", | ||
"API": "API", | ||
"GitHub": "GitHub" | ||
}, | ||
"categories": { | ||
"Introduction": "Introduction", | ||
"Features": "Features", | ||
"API": "API" | ||
} | ||
}, | ||
@@ -27,0 +108,0 @@ "pages-strings": { |
[ | ||
"5.3.1", | ||
"5.3.0", | ||
"5.2.0" | ||
] |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
847244
87
14261
1