I'm currently working on validating some data with the express-validator middleware v6.10.1, but I'm encountering an unusual error when testing it with Postman.
Here's my code:
const { check, validationResult } = require('express-validator')
router.post('/', [
check('name', 'Required Field!').not().isEmpty(),
check('email', 'Required Field!').not().isEmpty(),
check('email', 'Not Valid Email Format!').isEmail(),
check('password', 'Required Field!').not().isEmpty(),
check('password', 'Password Must Contain At Least 10 Characters!').isLength({ min: 10 }),
check('type', 'Required Field!').not().isEmpty()
], (req, res) => {
const errors = validationResult()
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() })
}
res.send('users route...')
})
The error message displayed in the console:
TypeError: Cannot read property 'express-validator#contexts' of undefined
I'm seeking help to understand and resolve this error. Any assistance would be greatly appreciated.