
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
express-validation-map
Advanced tools
Under the inspiration of these libraries [express-validation](https://www.npmjs.com/package/express-validation) and [minimalistic-js](https://www.npmjs.com/package/minimalistic-js), I have written my own library which validate data (more convenient for me
Under the inspiration of these libraries express-validation and minimalistic-js, I have written my own library which validate data (more convenient for me) as middleware, for the framework "express.js".
npm install express-validation-map -S
Add a middleware to the any router and throw a validationMap object into it.
Example a part server.js file:
app.route('/user/:id')
.put(
onValidation(updateUserValidationMap),
(req, res) => {
// Some logic
// ...
}
);
....
Example a part server.js file:
const updateUserValidationMap = {
config: {
code: 502,
message: "custom"
},
params: {
id: {
methods: {
required2: methods.isRequired,
isInteger: methods.isInteger
},
messages: {
required2: isRequiredText,
isInteger: isOnlyIntegerText
}
},
},
body: {
firstName: {
methods: {
required: methods.isRequired,
isName: methods.isName
},
messages: {
required: isRequiredText,
isName: isNameText
}
},
lastName: {
methods: {
required: methods.isRequired,
isName: methods.isName,
is23: is23,
},
messages: {
required: 'asdasdasdasd',
isName: isNameText,
is23: 'it is number 23'
}
},
email: {
methods: {
required: methods.isRequired,
isEmail: methods.isEmail,
},
messages: {
required: isRequiredText,
isEmail: isEmail
}
},
},
};
Where params
, body
and query
is input data and config
need only for define own properties:
code
- http status,
message
- 'erros.validations`
const validationMap = {
[query|params|body]: {
[field]: {
methods: {
key1: anyMethod1,
key2: anyMethod2,
key3: anyMethod3
},
messages: {
key1: messageForMethod1,
key2: messageForMethod2,
key3: messageForMethod3,
}
}
}
};
Enjoy :)
FAQs
Under the inspiration of these libraries [express-validation](https://www.npmjs.com/package/express-validation) and [minimalistic-js](https://www.npmjs.com/package/minimalistic-js), I have written my own library which validate data (more convenient for me
The npm package express-validation-map receives a total of 0 weekly downloads. As such, express-validation-map popularity was classified as not popular.
We found that express-validation-map 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.