Skip to content

docs(forms): show nullable number and Date models in signal forms guides - #72217

Open
MeAkib wants to merge 2 commits into
angular:mainfrom
MeAkib:docs/signal-forms-nullable-models
Open

MeAkib wants to merge 2 commits into
angular:mainfrom
MeAkib:docs/signal-forms-nullable-models

Conversation

@MeAkib

@MeAkib MeAkib commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Clearing a number or date input sets a number or Date field to null, so type those fields as number | null and Date | null. Also explain that date inputs only use YYYY-MM-DD strings when the field is a string, and drop the new Date() conversion tip, since a Date | null field receives Date objects directly.

The second commit applies the same change to the number input examples in the validation guide, the form logic guide and the NG8022 error page.

Clearing a number or date input sets a number or `Date` field to `null`,
so type those fields as `number | null` and `Date | null`. Also explain
that date inputs only use `YYYY-MM-DD` strings when the field is a
string, and drop the `new Date()` conversion tip, since a `Date | null`
field receives `Date` objects directly.
@pullapprove
pullapprove Bot requested a review from josephperrott November 26, 2026 03:34
@angular-robot angular-robot Bot added area: docs Related to the documentation area: forms labels Nov 26, 2026
@ngbot ngbot Bot added this to the Backlog milestone Nov 26, 2026

@JeanMeche JeanMeche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for highlithing this.

I've opened #72230 / #72231 to improve dx around this.

…examples

Clearing an `<input type="number">` bound with `[formField]` sets the field
to `null`, so a model typed as `number` does not describe the values it can
hold. The `min()`/`max()` example in the validation guide, the Order, Age
and Inventory examples in the form logic guide and both NG8022 examples
still bound a non-nullable number to a number input.

Type those fields as `number | null`. Where a `when` condition compares the
value with `<`, fall back to `0` for `null`, which keeps the current
behavior and compiles with the nullable type.
@MeAkib
MeAkib force-pushed the docs/signal-forms-nullable-models branch from a93b2b6 to aa729be Compare December 1, 2026 05:51
@MeAkib

MeAkib commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@JeanMeche I added a second commit after your approval, following the note on #72231. A few more examples still bound a non-nullable number model to <input type="number">:

  • guide/forms/signals/validation.md: the age/rating min()/max() example
  • guide/forms/signals/form-logic.md: the Order, Age and Inventory examples
  • reference/errors/NG8022.md: both examples

They now use number | null. Where a when condition compares the value with <, it falls back to 0 for null, which keeps the current behavior. The first commit is unchanged apart from a rebase on main.

@MeAkib
MeAkib requested a review from JeanMeche December 1, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation area: forms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants