Skip to content
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

Custom Validator Directive won't fire when signal changes #55730

Open
acalvomanxa opened this issue May 8, 2024 · 2 comments
Open

Custom Validator Directive won't fire when signal changes #55730

acalvomanxa opened this issue May 8, 2024 · 2 comments
Labels
area: forms cross-cutting: signals feature Issue that requests a new feature
Milestone

Comments

@acalvomanxa
Copy link

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

Yes

Description

As you can see in the image, I have an input with a custom validator and I send a signal into it.
Inside the validator, I get that value and use it in my validate function.

The validate function is only called when the input value that has the validator changes, but doesn't when the "entregaName" value changes. I understand that maybe this is not the correct way of doing it, however it's what seems common sense.

My use case is I want to validate an input whenever the users click a button. I can't use async validators because they would fire each time.

In the past I've used the hack of adding a space to the input and then deleting the space with a settimeout, thus activating the validation function, aswell as adding or removing errors from the control programatically, but it doesn't seem like the proper way of doing it.

image

image

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.5
Node: 18.16.0
Package Manager: npm 9.5.1
OS: win32 x64

Angular: 17.3.5
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.5
@angular-devkit/build-angular   17.3.5
@angular-devkit/core            17.3.5
@angular-devkit/schematics      17.3.5
@schematics/angular             17.3.5
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else?

No response

@acalvomanxa
Copy link
Author

Another hack I found is the following

image

@JeanMeche JeanMeche added the needs reproduction This issue needs a reproduction in order for the team to investigate further label May 8, 2024
@alxhub alxhub added feature Issue that requests a new feature area: forms cross-cutting: signals and removed needs reproduction This issue needs a reproduction in order for the team to investigate further labels May 8, 2024
@ngbot ngbot bot modified the milestone: Backlog May 8, 2024
@alxhub
Copy link
Member

alxhub commented May 8, 2024

Validators are not integrated at all with signals and not expected to be reactive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms cross-cutting: signals feature Issue that requests a new feature
Projects
Status: No status
Development

No branches or pull requests

3 participants