No errors with express-validator isEmpty
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
In your snippet you have not added a validtor to check if a value is not empty.You could achieve this by doing:
check('firstName', 'First Name is required').notEmpty()
.notEmpty() adds a validator to check if a value is not empty; that is, a string with a length of 1 or bigger.
https://express-validator.github.io/docs/validation-chain-api.html#notempty