router.post(
"/",
[
body("name").isLength({ min: 3 }),
body("email").isEmail(),
body("password").isLength({ min: 5 }),
],
(req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
res.send(req.body);
}
);
I want to replace the individual parameters checking by another middleware validation function which checks using checkSchema https://express-validator.github.io/docs/api/check-schema#schema as i would be more structured and easier to use .
I tried using the documentation and tutorials but could not find any solution