question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

validationErrors(true) only map the last error

See original GitHub issue

Hi,

With this code :

req.assert('email', 'empty e-mail').notEmpty();    
req.assert('email', 'invalid e-mail').isEmail();    
var errors = req.validationErrors();  
console.dir(errors);

the console returns :

[ { param: 'email',
    msg: 'empty e-mail',
    value: '' },
  { param: 'email',
    msg: 'invalid e-mail',
    value: '' } ]

With this code :

req.assert('email', 'empty e-mail').notEmpty();    
req.assert('email', 'invalid e-mail').isEmail();    
var errors = req.validationErrors(true);  
console.dir(errors);

it returns only the last error :

{ email: 
{ param: 'email',
msg: 'invalid e-mail',
value: '' } }

An idea ?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
gustavohenkecommented, Oct 31, 2016

So, this has been explicitly documented, thanks to the request of @superclarkk.

Changing this behavior is likely to require the release of a major version. If more people require such change, I can make it happen in an eventual v3.0.0.

As usual, PRs are welcome.

0reactions
lock[bot]commented, Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get all validation errors from Angular 2 FormGroup
How can I get all validation errors from this.form ? I'm writing unit tests and want to include the actual validation errors in...
Read more >
The stub domain example returns validation errors #29158
--allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in the template. Only applies ...
Read more >
Angular validation errors made easy | by Luca Micieli - Medium
This component accepts a set of error messages together with parameters and shows them translated using @ngx-translate . Messages are just ...
Read more >
validationResult() - express-validator
Returns: an array of validation errors. Gets all validation errors contained in this result object. If the option onlyFirstError is set to true...
Read more >
Handling Validation Errors - python-jsonschema
If the error was caused by a non-validation error, the exception object will be here. Currently this is only used for the exception...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found