Repository navigation
feat(forms): date and datetime-local minimum/maximum bounds - #697
Merged
Merged
Conversation
minimum and maximum were numeric-only and refused on any non-number
field. They now also bound type: date (a YYYY-MM-DD string) and
type: datetime-local (a whole-minute YYYY-MM-DDTHH:MM string), in the
field's own format, inclusive, either side optional.
- Activation refuses a bound that is not a real date/time in the
field's format, a minimum later than maximum, a string bound on a
number field, and any bound on other types.
- Submission compares at full precision (09:00 == 09:00:00.000) and
answers 422 with "must be on or after/before <bound>".
- The input renders matching HTML min/max via a new ui field() min/max
option, restricted to number/date/datetime-local inputs.
- datetime-local bounds are whole minutes because browsers use min as
the step base and the default 60 s step would otherwise reject
ordinary values.
Relative bounds ("today") and conditional validation remain out of
scope. Part of #528.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Part of #528. This PR does the date-range half. Conditional validation is still open.
What changes
minimum/maximumnow also boundtype: dateandtype: datetime-localfields, written in the field's own format. Bounds are inclusive and either side can be left out.minimumlater thanmaximum, a string bound on anumberfield, and any bound on other types.09:00=09:00:00.000,17:30:00.001>17:30), and an out-of-range value gets a 422 field error: "must be on or after …" / "must be on or before …".min/max. This addsmin/maxoptions to ui'sfield(), which accepts them only onnumber,dateanddatetime-localinputs, only with number- or date-shaped values, and always escapes them.Why reuse
minimum/maximumrather than addmin/maxA field already has exactly one value bound:
minimum/maximum. The field'stypealready decides what those bounds mean. Adding a second pair would mean either pair could appear on the wrong type, and both would need cross-refusal rules. Reusing the keys keeps the vocabulary JSON-Schema-shaped like the rest offieldSchema(minLength,pattern,enum). YAML 1.2 (theyamlpackage) keeps unquoted2026-01-01as a string, so authors can leave dates unquoted. The README examples quote them anyway, to be safe.Deliberate narrowing
datetime-localbounds are whole minutes. Browsers useminas the step base, and the default step is 60 s. A bound with seconds would make the picker reject ordinary values while the server accepted them.min/max, because with the defaultstep=1a fractionalminimumwould make browsers reject valid values.Note on the triage comment
The triage comment on #528 retained the issue as evidence-gathering only. This PR implements the absolute date-range subset on the owner's direction in this session. The issue body lists that subset as an acceptable bounded shape ("field-local RFC 3339 date validator with explicit absolute/relative bounds").
Evidence
npm run typecheck: passpackages/formstests: 17/17, including two new [Gap]: add bounded conditional and date-range validation to forms #528 tests (submission, rendering, activation refusals)packages/uitests: 96/96, including a newfield()min/max testnpm run verify: exit 0. This covers lint, typecheck, check, core tests 799/799, every workspace's verify, the add-on manifest check (packages/forms/urlcode.jsonregenerated), package audit and add-on integration.CI passing is not a security review.
🤖 Generated with Claude Code