Skip to content

fix(isISO8601): validate signed ordinal dates in strict mode - #2865

Open
abhijeet117 wants to merge 1 commit into
validatorjs:masterfrom
abhijeet117:fix/isISO8601-signed-ordinal-strict
Open

fix(isISO8601): validate signed ordinal dates in strict mode#2865
abhijeet117 wants to merge 1 commit into
validatorjs:masterfrom
abhijeet117:fix/isISO8601-signed-ordinal-strict

Conversation

@abhijeet117

Copy link
Copy Markdown

Summary

In strict mode, isValidDate matched ordinal dates with a pattern that had no sign prefix, even though the main isISO8601 patterns accept a leading + or - on the year. Signed ordinal dates therefore fell through to the calendar-date branch, where the three-digit day of year was split into a bogus month and day: valid dates like +2009-145 were rejected, and others passed without any day-of-year check. The pattern now accepts an optional sign and routes these to the existing ordinal validation, including its leap-year bound.

Testing

Reproduced before the fix: isISO8601('+2009-145', { strict: true }) returned false while the unsigned 2009-145 returned true. Added a focused case in test/validators.test.js covering signed valid dates, a leap-year day 366, and a non-leap day 366 rejection.

Checklist

  • bug reproduced before fix
  • root cause identified
  • bug fixed
  • tests passed

@codecov

codecov Bot commented Aug 23, 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 (917c3c8).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2865   +/-   ##
=========================================
  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.

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