Good night. I have to validate if every element in the array has a username. I'am currently using express-validator successfuly to validate only one user, but I dont know how to deal with the array.
I want to do somethink like
req.checkBody('username', 'username is required').isEmail();
But for each element in the array. In which case the following input sends an error for the first argument in the array given that it has no username. I was thinking something like
req.checkBody('req.body[1].username', 'username is required').isEmail();
whould work but it dosn't.
[{
"password": "123",
"nombre":"kila",
},
{
"username": "vanilla@skalia.com",
"password": "123",
}]
Aucun commentaire:
Enregistrer un commentaire