Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs(signal-forms-tutorial): update new schema syntax in example code.#62702

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ttma1046 wants to merge1 commit intoangular:prototype/signal-forms
base:prototype/signal-forms
Choose a base branch
Loading
fromttma1046:signal-forms-tutorial-fix

Conversation

ttma1046
Copy link

@ttma1046ttma1046 commentedJul 18, 2025
edited
Loading

(chandlerfang@gmail.com)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

old signal form 'Schema' syntax in the example code in signal forms tutorial

What is the new behavior?

update to new signal form 'schema' function syntax in the example code in signal forms tutorial

Does this PR introduce a breaking change?

  • Yes
  • No

@pullapprovepullapprovebot requested a review fromcrisbetoJuly 18, 2025 05:48
@angular-robotangular-robotbot added the area: docsRelated to the documentation labelJul 18, 2025
@ngbotngbotbot added this to theBacklog milestoneJul 18, 2025
@ttma1046
Copy link
Author

/gemini review

Copy link

@gemini-code-assistgemini-code-assistbot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR correctly updates the signal forms schema syntax in the tutorial. I've found one issue in an example where a custom validation error is created as a plain object literal instead of usingValidationError.custom(). Using the factory function is safer and more aligned with the API. I've left a suggestion to fix this.

required,
validate,
} from '@angular/forms/experimental';

export const friendSchema: Schema<Friend> =(friend) => {
export const friendSchema = schema<Friend>((friend) => {
required(friend.name);
required(friend.email);
validate(friend.email, ({value}) => {
return value().includes('@') ?
undefined :
{ kind: 'emailFormat' };

Choose a reason for hiding this comment

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

high

The object literal{ kind: 'emailFormat' } is not an instance ofValidationError. While this might work due to structural typing in some cases, it's not type-safe and goes against the intended API usage. It's best practice to useValidationError.custom() to create custom validation errors. This ensures your code is robust and aligned with the framework's validation error handling.

For this specific case, you could also use the built-inValidationError.email() which produces an error withkind: 'email'.

Using eitherValidationError.custom() orValidationError.email() will require importingValidationError from@angular/forms/experimental.

Suggested change
{ kind: 'emailFormat' };
ValidationError.custom({ kind: 'emailFormat' });

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

@crisbetocrisbetoAwaiting requested review from crisbeto

Assignees
No one assigned
Labels
area: docsRelated to the documentation
Projects
None yet
Milestone
Backlog
Development

Successfully merging this pull request may close these issues.

1 participant
@ttma1046

[8]ページ先頭

©2009-2025 Movatter.jp