Permalink
Browse files

Add context info to validation error

  • Loading branch information...
1602 committed Apr 30, 2013
1 parent 870bb66 commit 64be978b9759bb150b054c07eb4b782139aa9b33
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/validations.js
  2. +6 −0 test/validations.test.js
View
@@ -595,6 +595,7 @@ function ValidationError(obj) {
this.message = 'Validation error';
this.statusCode = 400;
this.codes = obj.errors && obj.errors.codes;
+ this.context = obj && obj.constructor && obj.constructor.modelName;
Error.call(this);
};
View
@@ -103,6 +103,12 @@ describe('validations', function() {
});
});
+ it('should allow to modify error after validation', function(done) {
+ User.afterValidate = function(next) {
+ next();
+ };
+ });
+
});
});

0 comments on commit 64be978

Please sign in to comment.