Skip to content

fix(parse): reject incomplete format matches - #152

Open
awais-ur-rehman wants to merge 1 commit into
knowledgecode:masterfrom
awais-ur-rehman:feat/reject-incomplete-date-input
Open

awais-ur-rehman wants to merge 1 commit into
knowledgecode:masterfrom
awais-ur-rehman:feat/reject-incomplete-date-input

Conversation

@awais-ur-rehman

Copy link
Copy Markdown

Summary

Parsing 2025 against YYYY-MM-DD currently succeeds even though the month and day are absent. Record required-token matching failures in preparse and reject them in the shared validator used by parse and isValid, while preserving parsed components and intentional short formats or ellipsis.

PreparseResult gains an optional _error: true field on mismatches; successful result shapes are unchanged.

Breaking changes

None. PreparseResult adds an optional error flag on failed matches.

Testing

Added 20 regression cases, with nine cases failing before the fix. Full npm test passes all 2373 tests after rebuilding; npm run lint, npm run ts, npm run build, and git diff --check pass on Node 24/macOS. Other runtime/platform combinations were not exercised locally.

Manual check: isValid("2025", "YYYY-MM-DD") returns false and parse returns an invalid Date; the same input with YYYY remains valid.

AI assistance

OpenAI Codex assisted with investigation, implementation, regression tests, review, and validation.

@knowledgecode
knowledgecode self-requested a review November 3, 2026 08:03

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant