ctavan/express-validator — pull request #103 by kyfr59 (2014-11-02 15:07:14+00:00)
Title: Reverse order when mapping errors

When I use express-validator, I like to map errors to handle these like that in my views :

<% if(errors && errors.email) { %>

<%= errors.email.msg %>

<% } %>

The problem is that when there's multiples errors on a field :

req.assert('email', 'Email required).notEmpty();
req.assert('email', 'Invalid email').isEmail();

mapping process only keeping the last error, in my example "Invalid email" while email field is empty.

To avoid this, I simply reversed the array before map.