Skip to content

fix(isISO8601): validate end-of-day times consistently - #2879

Open
Jerry-val wants to merge 2 commits into
validatorjs:masterfrom
Jerry-val:fix/iso8601-end-of-day
Open

fix(isISO8601): validate end-of-day times consistently#2879
Jerry-val wants to merge 2 commits into
validatorjs:masterfrom
Jerry-val:fix/iso8601-end-of-day

Conversation

@Jerry-val

Copy link
Copy Markdown

Fixes #2858.

isISO8601('2009-01-01T24:00:00') currently returns false, while mixed separators such as T24:0000 and nonzero end-of-day components such as T240030 and T24:00.0001 are accepted. The 24:?00 alternative bypasses the separator capture used by the seconds backreference.

Handle hour 24 in a separate alternative in both separator modes. This accepts basic and extended end-of-day representations, preserves reduced precision and zero fractions, and requires all lower-order components to be zero. The ordinary-time branch is guarded against falling back to interpreting 24 as a seconds-only value. Calendar validation and timezone syntax are unchanged.

Regression cases cover valid and invalid end-of-day inputs under all four combinations of strict and strictSeparator, including whitespace separation. No generated distribution files are included.

Validation

  • Before the source fix: npm test -- --grep 'ISO 8601' — 7 passing, 10 failing; failures reproduce the rejected midnight and accepted mixed-separator inputs.
  • After the fix: the same command — 17 passing.
  • npm test — 335 passing, including all distribution builds and ESLint.
  • 96 additional assertions across the generated Node, browser, and minified browser distributions — passed.
  • git diff --check — passed.
  • Environment: Node.js 24.19.0, npm 12.0.2, macOS.

References

Checklist

  • PR contains only related changes.
  • README update assessed: no public API or option changes.
  • Regression tests written and verified before and after the fix.
  • References provided.

AI assistance: implemented, tested, and independently reviewed with Codex.

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a79ff98) to head (7254549).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2879   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nrps9909 nrps9909 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated exact head 7254549ca296f5605eb226a7b7f816ac2086c9fa against a79ff980ab14257e795332989e497bdff3218e87.

The PR tests on unchanged base reproduce 10 failures (7 passing); full head npm test passes 335 tests, including builds and ESLint on Node 24.15.0. All 13 exposed upstream checks pass.

An independent corpus runs 78,908 observations on each of source, Node, browser, and minified browser:

  • 57,692 hour-24 observations enumerate minute/second values 00–59 with basic, extended, and mixed separators, plus selected reduced-precision/fraction cases, across all four strict-option combinations.
  • 480 additional separator/timezone controls.
  • 20,736 ordinary-time compatibility observations use unchanged base behavior as the oracle.

Base has 616 mismatches per form; head has zero, including zero ordinary-time changes in this corpus. This validates the scoped end-of-day behavior and compatibility controls, not exhaustive calendar/timezone or ISO conformance. Keeping hour 24 separate resolves the reported mixed-separator and nonzero-component acceptance paths.

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.

isISO8601 rejects T24:00:00 and accepts mixed separators

2 participants