You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature in Angular's ReactiveForms enables you to create a built-in validator inside a custom form control, which will cause it to be invalid and/or have errors. This uses setValidators behind the scenes.
There are a few issues with this approach in ReactiveForms:
Using setValidators does not automatically run the validations again, so the control might not get invalid even though it should be.
If the custom control component was destroyed, the validator is removed. If the control was previously invalid, it might be become valid again when running update value and validity. This is usually not the desire behavior, since this case occurs usually when you hide views from the user, and you don't really want logic to change as a result. (For example, if you have a form that is divided to multiple routes)
To support NG_VALIDATOR, we'll have an internal function that can add errors (not validators) to the validation state of the control.
We'll create FormCustomValidatorDirective that will use this internal function in hook into the NG_VALIDATORS provider to make this work.
[!question]
Do we want this only for the compatibility layer, or do we also want to supply our own API for this?
The text was updated successfully, but these errors were encountered:
This feature in
Angular
'sReactiveForms
enables you to create a built-in validator inside a custom form control, which will cause it to be invalid and/or have errors. This usessetValidators
behind the scenes.There are a few issues with this approach in
ReactiveForms
:setValidators
does not automatically run the validations again, so the control might not get invalid even though it should be.To support NG_VALIDATOR, we'll have an internal function that can add errors (not validators) to the validation state of the control.
We'll create
FormCustomValidatorDirective
that will use this internal function in hook into theNG_VALIDATORS
provider to make this work.The text was updated successfully, but these errors were encountered: