angular-auto-validate icon indicating copy to clipboard operation
angular-auto-validate copied to clipboard

Number validation not showing when also required

Open abobwhite opened this issue 9 years ago • 7 comments

I just ran across an issue - and I'm not sure if it's an angular issue or angular-auto-validate. I have an <input type="number" required /> and I seem to always be getting the required error validation message even i've typed something (non-numeric) into the input. I am expecting the error message to be the number error message, not the required message.

The angular demo on https://docs.angularjs.org/api/ng/input/input%5Bnumber%5D seems to work as expected with required and number.

Thoughts?

abobwhite avatar Mar 18 '15 21:03 abobwhite

Hmmm, most likely if you put a non-numeric into the field the formatter in angular is failing so the model is not updating so it appears to auto-validate that the field has not got anything in. I'll investigate.

jonsamwell avatar Mar 20 '15 00:03 jonsamwell

Thanks. I found a workaround by creating a directive allow-invalid which always returns ngModelCtrl.$viewValue from $parsers.push that seems to put the invalid value on the model but it's kind of a hack. The only reason I believe this could be auto-validate issue is because it is behaving as expected on the above example in the angular documentation.

abobwhite avatar Mar 20 '15 04:03 abobwhite

Yeah this is a problem with the library specifically the debounce function on the ngModelDecorator. Both the number and required validation errors are coming through but required is get picked over number. Need to thing about handling this.

jonsamwell avatar Mar 22 '15 02:03 jonsamwell

Any movement on this?

abobwhite avatar Apr 16 '15 18:04 abobwhite

Sorry I did look at this but haven't figure out a fix yet.

jonsamwell avatar Apr 20 '15 05:04 jonsamwell

Any fix for this please?

karolwebsky avatar Dec 02 '15 14:12 karolwebsky

Sorry I completely forgot about this bug - I'll take a look

jonsamwell avatar Dec 02 '15 15:12 jonsamwell