Some errors in the previous PR

This commit is contained in:
Julien Guimont 2011-11-25 10:43:50 -05:00
parent 3ce01d11b2
commit 001a962606
1 changed files with 7 additions and 3 deletions

View File

@ -116,7 +116,6 @@ Validatable.prototype.isValid = function (callback) {
var inst = this; var inst = this;
this.constructor._validations.forEach(function (v) { this.constructor._validations.forEach(function (v) {
if (v[2] && v[2].async) { if (v[2] && v[2].async) {
valid = false;
async = true; async = true;
wait += 1; wait += 1;
validationFailed(inst, v, done); validationFailed(inst, v, done);
@ -133,6 +132,7 @@ Validatable.prototype.isValid = function (callback) {
asyncFail = asyncFail || fail; asyncFail = asyncFail || fail;
if (--wait === 0 && callback) { if (--wait === 0 && callback) {
validationsDone.call(inst, function () { validationsDone.call(inst, function () {
if( valid && !asyncFail ) cleanErrors(inst);
callback(valid && !asyncFail); callback(valid && !asyncFail);
}); });
} }
@ -140,8 +140,12 @@ Validatable.prototype.isValid = function (callback) {
}); });
if (!async) {
if (valid) cleanErrors(this); if (valid) cleanErrors(this);
if (!async && callback) callback(valid); if (callback) callback(valid);
}
return valid; return valid;
}; };