angular-validator icon indicating copy to clipboard operation
angular-validator copied to clipboard

validator.provider -> validate promise -> error is not called after all the validators execute

Open ionutmandra opened this issue 10 years ago • 0 comments

Hi. I have let's say 5 validators on a form. On save, i would like to be notified when validation fails, so I can iterate over the failed validators and have some logic.

The problem is that after first validation fails, it calls validatedError function, which calls the validate promise error, ( if (count.error++ === 0) { call promise ) so i get notified that my validation operation failed, but I cant detect when all the validators are completed. A quick and dirty fix would be to change the validatedError and instead of x(); to have $timeout(function () { x(); });, so the root promise error would still be called just one time, but after all the operations on current stack (all validators operatios) complete.

I understand that each control get marked as invalid after all validations happen, and that my $validator.validate(...).success(function () {}).error(function () {}); error get's called, but is there any way to know when all validations are completed ? maybe I am missing some info at this point

ionutmandra avatar Jun 26 '15 11:06 ionutmandra