express-validator: Chaining check causes duplicated errors

request.check('email', 'Email is not valid').notEmpty().notNull().isEmail();

With no “email” field set this will return 3 repeatitions of the same message. Shouldn’t the error message be unified on chained call like this?

Thank you

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 25 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hi everyone! The fix for this has finally landed in v3.0.0!

req.getValidationResult().then( result => {
  var errors = result.useFirstErrorOnly().array(); // enjoy an array with no duplicated errors for any given parameter!
})

Hi @TheHominid. I’m glad that you found something that works for you at the moment.

Anyway, with the introduction of #269, it’s easy to add opt-in support to new methods that fix issues like this. That’s my plan, so this issue can finally be closed.