Skip to content

Comments

feat(forms): support string values in min/max validators for date and time inputs#67196

Open
brunoredes wants to merge 1 commit intoangular:mainfrom
brunoredes:forms-signal-min-max-validator
Open

feat(forms): support string values in min/max validators for date and time inputs#67196
brunoredes wants to merge 1 commit intoangular:mainfrom
brunoredes:forms-signal-min-max-validator

Conversation

@brunoredes
Copy link

Add overloads to min() and max() validators to accept string values, enabling validation for <input type="date">, <input type="time">, <input type="datetime-local">, and similar inputs that produce ISO-formatted string values.

String comparison uses lexicographic ordering, which correctly handles ISO date/time formats where alphabetical order matches chronological order.

PR Checklist

Please check if your PR fulfills the following requirements:

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?

The min() and max() validators only accept numeric values as the constraint argument. When used with string paths (such as , , or which produce ISO-formatted string values), passing a string like '2025-06-01' results in a TypeScript error:

This prevents using these validators for date/time inputs without workarounds.

Issue Number: #65676

What is the new behavior?

The min() and max() validators now support string values as constraints through new function overloads:

Number paths: Accept number | LogicFn<number, number | undefined> (unchanged)
String paths: Accept string | LogicFn<string, string | undefined> (new)
Mixed number | string | null paths: Accept numeric constraints for backward compatibility
String comparison uses lexicographic ordering, which correctly handles ISO date/time formats (YYYY-MM-DD, HH:MM, YYYY-MM-DDTHH:MM) where alphabetical order matches chronological order.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

The existing API remains fully backward compatible. All existing usages of min() and max() with numeric values continue to work unchanged. The new string overloads are purely additive.

@pullapprove pullapprove bot requested a review from crisbeto February 22, 2026 17:40
@google-cla
Copy link

google-cla bot commented Feb 22, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: forms labels Feb 22, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 22, 2026
@brunoredes brunoredes force-pushed the forms-signal-min-max-validator branch from a4a5b44 to b616783 Compare February 22, 2026 18:06
… time inputs

Add overloads to `min()` and `max()` validators to accept string values,
enabling validation for `<input type="date">`, `<input type="time">`,
`<input type="datetime-local">`, and similar inputs that produce ISO-formatted
string values.

String comparison uses lexicographic ordering, which correctly handles
ISO date/time formats where alphabetical order matches chronological order.
@brunoredes brunoredes force-pushed the forms-signal-min-max-validator branch from b616783 to 6cd45fb Compare February 22, 2026 19:05
@JeanMeche JeanMeche requested review from kirjs and removed request for crisbeto February 22, 2026 19:12
@JeanMeche
Copy link
Member

Thanks for the suggestion, looking at this item, the implementation might not be in line with what we want.

added @kirjs as a reviewer for better insights.

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

Labels

area: forms detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants