Repository navigation
fix(forms): validate date and datetime-local field submissions - #684
Merged
Merged
Conversation
admission() checked email and number formats but accepted any string for type: date and type: datetime-local. Validate the formats browsers submit (HTML valid date string / valid normalized local date and time string): YYYY-MM-DD, and YYYY-MM-DDTHH:MM with optional :SS and up to three fractional-second digits, no timezone offset. Impossible calendar values (2026-02-30, month 13, hour 24, year 0000) are refused with a 422 field error. No min/max date bounds (#528). Fixes #682 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.
Fixes #682
What changed
packages/forms/src/forms.ts:admission()now hasdateanddatetime-localbranches, placed alongside theemailbranch and matching its message style:date:YYYY-MM-DD(HTML "valid date string"). Error:must be a valid date.datetime-local:YYYY-MM-DDTHH:MM, with optional:SSand optional.f/.ff/.ffffractional seconds (HTML "valid normalized local date and time string" plus the non-normalized seconds forms a browser can send). There is no timezone offset, and the separator must beT. Error:must be a valid local date and time.2026-02-30,2027-02-29,1900-02-29, month00/13, day00, April 31, year0000, hour 24, minute 60, second 60.packages/forms/test/forms.test.ts): the sharedcontactflow gains optionalvisit(date) andcallback(datetime-local) fields. A new test covers valid dates (including leap days), malformed and impossible dates, datetime-local values with and without seconds and fractions, invalid datetime-local values (space separator,Z/offset, 4 fractional digits, out-of-range times), and empty optional fields still being admitted. With thesrcchange reverted, the new test fails.## Unreleased) updated. No page indocs/lists per-type validations, sincedocs/EXTENSIONS.mdlinks to the package README.Deliberate limits
max. A five- or six-digit year is refused here.Verification
npm run typecheck: cleannpm run verify: exit 0 (root 781/781, then every workspace verify, the add-on manifest check, package audit and the add-on integration tests)CI passing is not an independent security review.
🤖 Generated with Claude Code