It allows you to combine them in many ways so that you can validate and sanitize your express requests, and offers tools to determine if the request is valid or not, which data was matched according to your validators, and so on.
Note that, despite the name, express-validator might work with libraries that aren't express.js. The main requirement is that the HTTP server library you're using models its HTTP request object similarly to express.js, and contains these properties:
Cookieheader parsed as an object from cookie name to its value.
req.headers: the headers sent along with the HTTP request.
req.params: an object from name to value.
In express.js, this is parsed from the request path and matched with route definition path, but it can really be anything meaningful coming from the HTTP request.
req.query: the portion after the
?in the HTTP request's path, parsed as an object from query parameter name to value.
One example library that works out of the box with express-validator is Restify.
express-validator is on the npm registry! Install it using your favorite Node.js package manager:
npm install express-validator
yarn add express-validator
pnpm add express-validator