Skip to content

Allow validateOn and invalidateOn, in addition to updateOn for AbstractControl #23484

@rafehi

Description

@rafehi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions