Fix validations

This commit is contained in:
Anatoliy Chakkaev 2013-03-31 13:41:02 +04:00
parent 0776c51994
commit 6449f1ca72
1 changed files with 10 additions and 3 deletions

View File

@ -374,15 +374,22 @@ Validatable.prototype.isValid = function (callback, data) {
});
if (!async) {
validationsDone.call(inst, callback);
validationsDone.call(inst, function() {
if (valid) cleanErrors(inst);
if (callback) {
callback(valid);
}
});
}
function done(fail) {
asyncFail = asyncFail || fail;
if (--wait === 0 && callback) {
if (--wait === 0) {
validationsDone.call(inst, function () {
if (valid && !asyncFail) cleanErrors(inst);
callback(valid && !asyncFail);
if (callback) {
callback(valid && !asyncFail);
}
});
}
}