What I need: I need to add extra validation to input by adding attribute to this input.
Firstly, my plnkr example is here
What I'd tried?: I added directive, so when I add attribute to the input, the value of the input is being validated by regexp ^5$
. Also, I added required to the input. I am talking about 2nd input now (name of the input is input2
).
So, I'd added attributes "my-attribute" and "required". When there is nothing in input I expect two items in myForm.item[1].$error
: its ok – there are properties myAttribute
and required
. Now, I will add some to the input2, for example "abc", now I expect in myForm.item[1].$error
only myAttribute
property (because required validation is passed, but myAttribute
validation is not), but there is properties myAttribute
and parse
in myForm.item[1].$error
. What is parse
property? Why it is adding to $error
?
I should notice, that when I put 5 to the input2 myForm.item[1].$error
is empty, because both require and myAttribute validations passed (and this behaviour is expected).
Now, when I clear input2 there are properties parse
and myAttribute
again. Why? When field input2 is empty, I expect required
and myAttribute
in myForm.item[1].$error
, but there are no ones.
So, why I get strange property parse
in $error
and how I can make my example working?
Form example code was founded here and approach to validate input by directive was founded in answer to this post.