Skip to content

changed enitre logic for isIso8601 and it's test cases#2564

Open
jesroffrouk wants to merge 6 commits intovalidatorjs:masterfrom
jesroffrouk:bugfix/isISO8601
Open

changed enitre logic for isIso8601 and it's test cases#2564
jesroffrouk wants to merge 6 commits intovalidatorjs:masterfrom
jesroffrouk:bugfix/isISO8601

Conversation

@jesroffrouk
Copy link
Copy Markdown
Contributor

feat(isISO8601): Rewrote entire logic for isISO8601 to solve the issue of #2003

I rewrote the entire logic for isISO8601 to fix several unhandled edge cases and improve overall reliability. Specifically, this addresses:

Week-based date formats (e.g. 2023-W52-7)

Milliseconds without seconds (e.g. 2023-03-15T13:30.123Z)

Incorrect acceptance of dates like 2016-W53 due to regex-only checks

This also resolves #2003.

Key changes:

Removed strict and strictSeparator options, as they don’t align with ISO 8601:2019, which mandates the 'T' separator.

Consolidated validation into a single regex, followed by actual date component checks (rather than relying on regex to determine validity).

Added comprehensive handling for leap years, week formats, time zones, and date boundaries.

Skipped support for astronomical years and basic format (e.g., 20251231) — these can be added later if needed, but are uncommon in modern usage.

The updated validator now handles all extended ISO 8601 formats I could find and passes against a wide range of edge cases.

References:

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7fdc788) to head (36a3184).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2564   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2587      2603   +16     
  Branches       656       659    +3     
=========================================
+ Hits          2587      2603   +16     

☔ View full report in Codecov by Sentry.
📢 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.

@jesroffrouk
Copy link
Copy Markdown
Contributor Author

@rubiin can you please review this PR ?

Copy link
Copy Markdown
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

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

One quick comment to resolve the warning from codecov.

Also; this is a breaking change and it might be a while before we merge this. #2398 is also likely to be part of the next major release
@profnandaa is in charge of deciding when we want to go ahead with a new major release

Comment thread src/lib/isISO8601.js Outdated
@jesroffrouk
Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up! I’ll look forward to the Codecov warning soon.
Totally understand that this is a breaking change—I’m happy to provide support for anything related to this change in the next major release.
I’ll keep an eye out for updates from @profnandaa on that.

@jesroffrouk
Copy link
Copy Markdown
Contributor Author

@profnandaa Could you please share an approximate timeline for the next major release? If it's going to take some time, I’ll go ahead and fix the current issue #2003 with minimal tweaks. Otherwise, I can wait and align with the upcoming release.

@rubiin
Copy link
Copy Markdown
Member

rubiin commented Apr 27, 2026

fix mcs

@jesroffrouk
Copy link
Copy Markdown
Contributor Author

working on it asap

Copy link
Copy Markdown
Contributor Author

@jesroffrouk jesroffrouk left a comment

Choose a reason for hiding this comment

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

Docs: kept my own changes for isISO8601 and aligned the remaining sections with the latest master branch. Merge conflicts were resolved only in the README file

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 returns true for an invalid iso8601 date

3 participants