Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add context info to validation error

  • Loading branch information...
commit 64be978b9759bb150b054c07eb4b782139aa9b33 1 parent 870bb66
@1602 authored
Showing with 7 additions and 0 deletions.
  1. +1 −0  lib/validations.js
  2. +6 −0 test/validations.test.js
View
1  lib/validations.js
@@ -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
6 test/validations.test.js
@@ -103,6 +103,12 @@ describe('validations', function() {
});
});
+ it('should allow to modify error after validation', function(done) {
+ User.afterValidate = function(next) {
+ next();
+ };
+ });
+
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.