ctavan/express-validator — pull request #6 by orfaust (2012-03-28 21:47:09+00:00)
Title: get errors with param name

I needed to retrieve the params name on validation errors, this would be a solution.
Follows the instructions I've included in my commits, I'll change or just remove them if you prefer.

To manage errors in templates you can get an object with key:msg pairs

req.assert('email', 'Not a valid email address').isEmail();
req.assert('password', 'Password is required').notEmpty();

var errors = req.getErrors();
if(errors)
console.log(errors);

In case of validation errors, will result in:

{ email: 'Not a valid email address',
password: 'Password is required' }

You can use the errors object in a template like:

if(errors.email)
input.error(type="text", name="email", value="#{values.email}")
span.error= errors.email
else
input.(type="text", name="email")