Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@ajoelp/express-validator
Advanced tools
## npm
npm i @ajoelp/express-validator
## yarn
yarn add @ajoelp/express-validator
import express from 'express';
import {body, query, params, validationResponseMiddleware} from '@ajoelp/express-validator'
const app = express();
app.get(
'/',
[
query({
'search': ['required', 'string'],
}),
params({
'userId': ['required', 'number'],
}),
body({
'email': ['required', 'email'],
'password': ['required', { type: 'string', message: 'This needs to be a string'}],
}),
validationResponseMiddleware,
(req, res) => res.send()
]
)
// express app setup...
Rule | Rule String | Rule Object |
---|---|---|
RequiredRule | required | { type: 'required', message: 'This is the message'} |
StringRule | string | { type: 'string', message: 'This is the message'} |
NumberRule | number | { type: 'number', message: 'This is the message'} |
MinRule | { type: 'min', value: 3, message: 'This is the message'} | |
MaxRule | { type: 'max', value: 4, message: 'This is the message'} | |
BooleanRule | boolean | { type: 'boolean', message: 'This is the message'} |
EmailRule | email | { type: 'email', regex: new RegExp(), message: 'This is the message'} |
DateRule | date | { type: 'date', message: 'This is the message'} |
NullableRule | nullable | |
CustomRule | { type: 'custom', rule: (value: string, request: Request) => Promise<boolean>, message: 'This is the message'} |
FAQs
Validation middleware for express
We found that @ajoelp/express-validator 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.