
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
express-validator-errors
Advanced tools
Error serializer for validation errors found in express-validator
Error json serializer for consistent errors when using express-validator
Combines errors from different sources:
errors.addToReq
- add your own errors to to express-validator's _validationErrors
without mixing in new validators
errors.serialize
- outputs all known validation errors
var errors = require('express-validator-errors')
var isValid = function (req) {
if (!req.body.objects)
errors.addToReq(req, 'objects', 'Root objects array is required', req.body)
req.checkBody(['objects', 0, 'title'], 'Title is required').notEmpty()
return req.validationErrors().length == 0
}
var expressReqHandler = function (req, res) {
if (isValid(req)) {
// ... happiness
} else {
res.json(400, errors.serialize(req))
}
}
// example input =>
// { objects: [{}] }
// outputs =>
// {
// "errors": [
// {
// "param": "objects.0.title",
// "msg": "Title is required"
// }
// ]
// }
errors.serialize
- outputs all known validation errors and the specific errors you ask it to output. Options are:
var errors = require('express-validator-errors')
var expressReqHandler = function (req, res) {
doSomethingThatSometimesErrors(function (err, data) {
if (err)
return res.json(500, errors.serialize(new Error('An error occurred'), req(
// ... happiness
}
}
// example output =>
// {
// "errors": [
// {
// "exception": {
// "message": "An error occurred",
// "stack": "... file stack trace ..."
// }
// }
// ]
// }
FAQs
Error serializer for validation errors found in express-validator
The npm package express-validator-errors receives a total of 40 weekly downloads. As such, express-validator-errors popularity was classified as not popular.
We found that express-validator-errors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.