fix(forms): allow multiple async validators#69625
Open
JeanMeche wants to merge 1 commit into
Open
Conversation
When a parent form element defines an async validator, its resource's `params` function needs to evaluate `syncValid()`, which causes unvisited child form nodes to be lazily instantiated. If any of these lazily instantiated child nodes also define an async validator, their resource is initialized while the parent's `params` function is still evaluating. This incorrectly triggers Angular core's `NG0992` guard (`Cannot create a resource inside the params of another resource`). This commit exports `ɵsetInParamsFunction` and `ɵisInParamsFunction` from `@angular/core` and uses them in `FieldMetadataState.runMetadataCreateLifecycle` to explicitly detach the lazy creation of form metadata from the parent's reactive `params` context. fixes angular#69620
JeanMeche
commented
Jul 2, 2026
Comment on lines
+39
to
+40
| const wasInParams = ɵisInParamsFunction(); | ||
| if (wasInParams) ɵsetInParamsFunction(false); |
Member
Author
There was a problem hiding this comment.
The alternative I'm thiking of, is that would be done as part of untracked but it would make that function more load bearing than it should.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a parent form element defines an async validator, its resource's
paramsfunction needs to evaluatesyncValid(), which causes unvisited child form nodes to be lazily instantiated. If any of these lazily instantiated child nodes also define an async validator, their resource is initialized while the parent'sparamsfunction is still evaluating. This incorrectly triggers Angular core'sNG0992guard (Cannot create a resource inside the params of another resource).This commit exports
ɵsetInParamsFunctionandɵisInParamsFunctionfrom@angular/coreand uses them inFieldMetadataState.runMetadataCreateLifecycleto explicitly detach the lazy creation of form metadata from the parent's reactiveparamscontext.fixes #69620