feat(forms): support string values in min/max validators for date and time inputs#67196
Open
brunoredes wants to merge 1 commit intoangular:mainfrom
Open
feat(forms): support string values in min/max validators for date and time inputs#67196brunoredes wants to merge 1 commit intoangular:mainfrom
brunoredes wants to merge 1 commit intoangular:mainfrom
Conversation
|
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. |
a4a5b44 to
b616783
Compare
… 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.
b616783 to
6cd45fb
Compare
Member
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.
Add overloads to
min()andmax()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?
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?
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.