ui-validate
ui-validate copied to clipboard
validating when required = false, and ng-disabled true
The issue can be seen in this plunker:
https://plnkr.co/edit/pbLlYkCVTSo1HV8KiXB2?p=preview
Working as expected for me.
Leave the box empty, change dropdown from "Everyday" to "Cancel"
Expected behavior: $scope.testForm.$error is an empty object. Both "min" and "required" rules disappear from it Since the field is disabled, no validation rules should be placed on it
Actual behavior: $scope.testForm.$error is not an empty object. "required" rule disappears as is standard for validation of disabled fields in angular. "min" is still listed in the $scope.testForm.$error obj. It shouldn't be there. Once the field is disabled, no validation should be taking place on it, thus there should be nothing in the $error object
The reason you see the required rule disappear is because you have ng-required make it not required when cancelled. This has nothing to do with the input disabled state. If you change it to just required="true" you will see that the rule still applies even if it is disabled. Its not documented that disabling a field should remove its validation constraints.
oh fiddle sticks, duh, sorry about that
perhaps a feature request for ui-validate-disable="true" attribute then?