I have following validation rules (nodejs, express-validator)
---------------------
check('email').not().isEmpty().withMessage('email is required'),
check('email').isEmail().withMessage('email not valid'),
---------------------
Now if I submit the form without an email address value it will have the following errors.
email is required
email not valid
I want to check email format only if email value exists, so that only one error message will be there, either 'email is required' or 'email not valid'.
any suggestions?