I am facing an issue with express-validator, when I use its body validation like body('email').isEmail()
or any type of validation then after that VS Code don't show me any suggestions.
router.post('/register', [
body('email').isEmail(),
body('password', 'Password must be 7 characters long').isLength({ min: 7 })
], (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
});
when I use []
to create an array of body validation then vs code stop giving me suggestion and if I remove those []
then I can't use suggestion on validations.
When I use []
:
When I type res.s
then I should get suggestion/ emmet like send, status etc. but I don't get any.
When I don't use []
:
When I type body('email').
I should get suggestions / emmet like isEmail()
, isLength()
etc. but I don't receive any emmet.
My package.json
file:
"dependencies": {
"bcryptjs": "^2.4.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-validator": "^6.12.2",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.0.9"
}
Anyone have any idea. Thanks for your help.
check the below link. In the example show in this link they are not using [] brackets