dresende/node-orm2 — pull request #96 by dxg (2013-04-05 05:54:17+00:00)
Title: Enable enumeration of all validation errors

Hey,

Whilst working on some front end code, I needed a way to highlight all validation errors in a HTML form.
ORM only returns the first failing validation, so I added a `getValidationErrors` method.
I also added a `type` attribute to validation errors so they are easily identifiable.

Here is my use case:
```js
// inside an express request handler
post.save( function(err) {
if (err) {
if (err.type != 'validation') {
next(err);
} else {
post.getValidationErrors(function (err, errors) {
if (err) return next(err);
res.send(errors: errors)
});
}
}
else {
res.send(id: post.id)
}
});
```

It would be cleaner if upon calling `save()` all validation errors were stored in a property like `post.errors` to avoid iterating through them twice.
What do you think?