Skip to content

feat(forms): support signal-based schemas in validateStandardSchema#66871

Open
SkyZeroZx wants to merge 1 commit intoangular:mainfrom
SkyZeroZx:feature/sf-dynamic-schema
Open

feat(forms): support signal-based schemas in validateStandardSchema#66871
SkyZeroZx wants to merge 1 commit intoangular:mainfrom
SkyZeroZx:feature/sf-dynamic-schema

Conversation

@SkyZeroZx
Copy link
Contributor

@SkyZeroZx SkyZeroZx commented Feb 2, 2026

Allow validateStandardSchema() to consume a computed schema so validation rules stay in sync when the schema changes over time.

This supports schemas stored in computed signals (e.g. zod schemas that depend on input signals) and ensures the effective schema updates after initialization instead of being captured once.

Fixes #66867

@Component({ /* ... */ })
class DynamicFormStandardSchema {
  // Signal that controls validation rule
  minLength = signal(3);

  model = signal({ name: '' });

  // Computed schema that changes reactively
  schema = computed(() =>
    z.object({
      name: z.string().min(this.minLength()),
    }),
  );


  myForm = form(this.model, (p) => {
    validateStandardSchema(p, () => this.schema());   // reactive schema validation
  });
}

@SkyZeroZx SkyZeroZx force-pushed the feature/sf-dynamic-schema branch 2 times, most recently from 0b02460 to 3736178 Compare February 2, 2026 21:38
@SkyZeroZx SkyZeroZx marked this pull request as ready for review February 2, 2026 21:38
@pullapprove pullapprove bot requested a review from crisbeto February 2, 2026 21:38
@crisbeto crisbeto requested review from mmalerba and removed request for crisbeto February 2, 2026 22:17
@ngbot ngbot bot modified the milestone: Backlog Feb 2, 2026
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Feb 3, 2026
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@pullapprove pullapprove bot requested review from crisbeto and devversion February 3, 2026 02:43
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Feb 3, 2026
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Feb 3, 2026
@JeanMeche JeanMeche force-pushed the feature/sf-dynamic-schema branch from 3736178 to d54f153 Compare February 3, 2026 08:53
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Feb 3, 2026
@JeanMeche JeanMeche added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Feb 4, 2026
@JeanMeche
Copy link
Member

JeanMeche commented Feb 4, 2026

Caretaker note: there is nothing to presubmit, the standard schema file isn't sync on G3.

#66904 should fix the underlying issue.

@leonsenft
Copy link
Contributor

While technically a feature, our merge infrastructure doesn't allow features in patches. Can you please change the commit message to fix(forms) or refactor(forms).

@leonsenft leonsenft added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 4, 2026
Allow `validateStandardSchema()` to consume a computed schema so
validation rules stay in sync when the schema changes over time.

This supports schemas stored in computed signals (e.g. zod schemas that
depend on input signals) and ensures the effective schema updates after
initialization instead of being captured once.

Fixes angular#66867
@SkyZeroZx SkyZeroZx force-pushed the feature/sf-dynamic-schema branch from d54f153 to b98f687 Compare February 5, 2026 00:27
@SkyZeroZx
Copy link
Contributor Author

While technically a feature, our merge infrastructure doesn't allow features in patches. Can you please change the commit message to fix(forms) or refactor(forms).

Done

@JeanMeche JeanMeche removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: forms detected: feature PR contains a feature commit forms: signals merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Support for signals with validateStandardSchema

4 participants