[Signal Forms] Update min and max to operate on number and Date values#68001
Closed
leonsenft wants to merge 7 commits into
Closed
[Signal Forms] Update min and max to operate on number and Date values#68001leonsenft wants to merge 7 commits into
min and max to operate on number and Date values#68001leonsenft wants to merge 7 commits into
Conversation
b3c23ef to
7e32650
Compare
alxhub
reviewed
Apr 2, 2026
JeanMeche
reviewed
Apr 2, 2026
14 tasks
jnizet
reviewed
Apr 3, 2026
Contributor
jnizet
left a comment
There was a problem hiding this comment.
I like my date input fields to be bound to iso date strings (which is the default native value of date inputs). Iso dates lexicographic order is also the chronological order. Can't min and max be applied to them?
|
Does this work properly with time inputs? They expect a string like "09:00" (see: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/time) |
de24419 to
f442288
Compare
The `min` and `max` validation rules previously handled `string` values to accommodate numbers bound to text inputs. However, this is no longer necessary as the control binding itself handles the conversion. This change removes string support from these rules, simplifying the types to `number | null`. The validation logic has been updated to use concrete checks (`value === null || Number.isNaN(value)`) to ensure safe TypeScript narrowing. Associated tests have been updated to: - Remove string-specific validation checks. - Add coverage for text input bindings. - Add coverage for empty input handling (standard behavior where empty sets model to null and skips validation). BREAKING CHANGE: `min` and `max` validation rules no longer support string values. Bound values must be numbers or null.
- Added `minDate()` and `maxDate()` for validating constraints on `Date` inputs. - `ReadonlyFieldState.min` and `.max` now return `Signal<NonNullable<TValue>`. This ensures that `min` and `max` inputs on custom controls can accept a reliable type (matching their value type). - Made the `TWrite` type parameter of `MetadataKey` contravariant to properly indicate that it's writable. - Added `LimitKey` as a convenience type for defining validation limit metadata (e.g. `MAX_NUMBER`, `MIN_DATE`). - Added `LimitSelectionKey` which can be used to bind a `LimitKey` with value-specific aggregation logic, to a generic metadata key (e.g. use `MAX_NUMBER` to aggregate numbers for `MAX`).
…te`/`maxDate` * Test that `minDate`/`maxDate` binds to `min`/`max` on date and time inputs * Test that `min`/`max` attribute can be set directly on date and time inputs * Relax type checker to allow `min`/`max` bindings on date and time inputs
… `minDate`/`maxDate`
… `minDate`/`maxDate`
Contributor
Author
|
@jnizet @martijnmelchers I've made changes to better accommodate date and time formats.
|
alxhub
approved these changes
May 6, 2026
Member
alxhub
left a comment
There was a problem hiding this comment.
Reviewed-For: fw-general, public-api
Member
|
This PR was merged into the repository. The changes were merged into the following branches:
|
alxhub
pushed a commit
that referenced
this pull request
May 6, 2026
- Added `minDate()` and `maxDate()` for validating constraints on `Date` inputs. - `ReadonlyFieldState.min` and `.max` now return `Signal<NonNullable<TValue>`. This ensures that `min` and `max` inputs on custom controls can accept a reliable type (matching their value type). - Made the `TWrite` type parameter of `MetadataKey` contravariant to properly indicate that it's writable. - Added `LimitKey` as a convenience type for defining validation limit metadata (e.g. `MAX_NUMBER`, `MIN_DATE`). - Added `LimitSelectionKey` which can be used to bind a `LimitKey` with value-specific aggregation logic, to a generic metadata key (e.g. use `MAX_NUMBER` to aggregate numbers for `MAX`). PR Close #68001
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.
stringsupport fromminandmaxvalidation rules. This is no longer necessary sinceFormFieldcan bind a numeric field to a text based control.minDateandmaxDatevalidation rules. These will bindminandmaxproperties as formatted strings fordateandmonthtype inputs only.