I am using express-validator 5.2.0 in a expressjs app. I implemented the validaiton on a form data. But it does not capture the errors and gives empty errors object. When validation runs it shows the "no error" when I submit the empty form. It should follow the error path and should display the error.
check('firstName', 'First Name is required').isEmpty()
is enforcing firstName
to be empty.
You will want to change that last part to .not().isEmpty()
, so that you invert the isEmpty
validator.
Might also be of your interest: https://github.com/express-validator/express-validator/issues/476