Add context info to validation error

This commit is contained in:
Anatoliy Chakkaev 2013-04-30 22:47:35 +04:00 committed by Raymond Feng
parent ba75af1490
commit 06641da2c6
2 changed files with 7 additions and 0 deletions

View File

@ -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 File

@ -103,6 +103,12 @@ describe('validations', function() {
});
});
it('should allow to modify error after validation', function(done) {
User.afterValidate = function(next) {
next();
};
});
});
});