Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept observable in mergeValidators/setValidators #56

Closed
rafaelss95 opened this issue Oct 26, 2020 · 1 comment
Closed

Accept observable in mergeValidators/setValidators #56

rafaelss95 opened this issue Oct 26, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@rafaelss95
Copy link
Contributor

rafaelss95 commented Oct 26, 2020

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
@NetanelBasal
Copy link
Member

You're welcome to create a PR.

@NetanelBasal NetanelBasal added the enhancement New feature or request label Oct 27, 2020
@ngneat ngneat locked and limited conversation to collaborators Jun 10, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants