netceteragroup/valdr

valdrEnabled Affecting Other Validations

Closed this issue · 3 comments

I ran into some strange behavior that I think is related to the valdr-enabled directive.

Basically, I see invalid values being considered valid in some very special cases. Here is a plunk that shows such behavior.

https://plnkr.co/edit/L4zbWBTZjllCarmJsTfj

So, in the plunk above, the second input, baz, has it's valdr-enabled set to !!foo.bar (the first input). Now, if I changed the value of bar to 1, then the validations on baz enable correctly. Now, if I change the value of bar back to zero, bar appears valid even though bar has a min value of 1 in my valdr configuration. The validations on baz are properly disabled, however.

Now, if I go from -1 to 0, then all validations function as expected. It is only when I change from a valid value, to an invalid value that I see the unexpected behavior.

Even stranger, if I remove the valdr-enabled directive from baz then all validations function as expected. Perhaps there is a problem with setting valdr-enabled to another validated field?

valdr-enabled is completly broken at the moment. The one use case you described is only one of many bugs coming with this directive.

@jdlubrano : There were some issues with your markup. First valdr-form-group add a form-group class itself so you don't need to use form-group explicitly. Second, because you have form-group on a higher level you weren't able to see the different coloring/style that valdr applies on the inputs when their validity changes. Next, you used ctrl.baz as a model for you second input which does not match with the object you define on the $scope.

I did the needed modifications within this plunker.

There you will be able to see that for your case, valdr-enabled works fine. The only time it doesn't work as expected is when for example you have value of 1 in the bar input and clicking the arrows you decrease the value to 0, but that is not connected with valdr-enabled but with the update of the ng-model and its state. I will take a more detailed look in it. However, if you decrease the value using the keyboard, the model will be updated properly and valdr-enabled will behave as expected even when going from 1 to 0 lets say.

@chillyistkult : please provide plunker or something similar explaining the issues you have with valdr-enabled.

@PesanskiGoran apologies for the errors in my Plunker. I see the behavior that you described in your version. Thank you for investigating the issue further.