-
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
enhancementNew feature or requestNew feature or request
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
[ ] Other... Please describe:
Current behavior
Currently mergeValidators/setValidators doesn't accept observables... we have the validateOn that deals with custom errors, but not with validators.
Expected behavior
I'd expect to see mergeValidators/setValidators accepting observables also, as setValue/patchValue.
What is the motivation / use case for changing the behavior?
I have an use case where I set the validators based on another formControl value, e.g.:
this.formGroup.controls.someControl.setValidators(
this.formGroup.select(({ dependent }) => dependent).pipe(
map(dependent => dependent === 'X' ? [Validators.required, Validators.minlength(3)], customValidator),
),
);Also, I think we could add support to accept observable in mergeErrors/setErrors, that would remove the necessity of having validateOn... but that's just an idea.
Environment
Angular version: 10.x.y
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request