-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
We can currently set a control to update its validation status on either 'blur', 'change' or ''submit.
Expected behavior
In addition to updateOn, it'd be useful to have the ability to independently set validateOn and invalidateOn.
To maintain backwards compatibility, setting updateOn is equivalent to setting both validateOn and invalidateOn to the same value. Setting validateOn or invalidateOn takes precedence.
What is the motivation / use case for changing the behavior?
Validation should be helpful without being intrusive or noisy. Ideally, we don't want to invalidate the control as soon as the user starts typing (it is obvious to a user that an email is invalid if they've only entered one character). Therefore, we desire to only invalidate the control on blur, as it is an indication that the user has finished entering that field.
However, if a field is invalid, and a user goes back to correct it, we'd like to immediately inform them as soon as it is valid. e.g. if the password field requires 6 characters but the user only entered 4, then went in changed it to 6, we'd like to immediately validate that, as maintaining the error message in that situation is confusing.
I'm not aware of another way of implementing this without creating a directive to track the focus state of the control. The proposed solution above is intuitive and straightforward from a user's POV.