validationErrors(true) only map the last error
See original GitHub issueHi,
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:
- Created 9 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.