Permalink
Browse files

return error as null when valid

  • Loading branch information...
1 parent e492817 commit d6889e6fd6c6e18989a6cbefb7ed595725632735 @ktmud ktmud committed Apr 24, 2014
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/validations.js
View
@@ -403,7 +403,7 @@ Validatable.prototype.isValid = function (callback, data) {
validationsDone.call(inst, function() {
if (valid) cleanErrors(inst);
if (callback) {
- callback(new ValidationError(this), valid);
+ callback(valid ? null : new ValidationError(this), valid);
}
});
}
@@ -414,7 +414,7 @@ Validatable.prototype.isValid = function (callback, data) {
validationsDone.call(inst, function () {
if (valid && !asyncFail) cleanErrors(inst);
if (callback) {
- callback(new ValidationError(this), valid && !asyncFail);
+ callback(valid ? null : new ValidationError(this), valid && !asyncFail);
}
});
}

0 comments on commit d6889e6

Please sign in to comment.