Add context info to validation error
This commit is contained in:
parent
ba75af1490
commit
06641da2c6
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -103,6 +103,12 @@ describe('validations', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow to modify error after validation', function(done) {
|
||||
User.afterValidate = function(next) {
|
||||
next();
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue