Skip to content

fix(isISO8601): reject week-zero dates (W00 is never a valid ISO 8601 week)#2774

Merged
rubiin merged 1 commit into
validatorjs:masterfrom
JSap0914:fix/iso8601-week-zero
Jun 17, 2026
Merged

fix(isISO8601): reject week-zero dates (W00 is never a valid ISO 8601 week)#2774
rubiin merged 1 commit into
validatorjs:masterfrom
JSap0914:fix/iso8601-week-zero

Conversation

@JSap0914

Copy link
Copy Markdown
Contributor

Bug

isISO8601 accepts W00 week dates as valid ISO 8601, but ISO 8601 week dates always start at W01 — week zero does not exist.

isISO8601('2024-W00')   // → true  ← false-positive
isISO8601('2024-W00-1') // → true  ← false-positive

Reference: ISO 8601 § Week date — "The first week of the year contains the first Thursday of the year" and is numbered W01; W00 is never assigned.

Fix

In both iso8601 and iso8601StrictSeparator regexes, change the week-number alternation from:

W([0-4]\d|5[0-3])   ← matches W00–W53

to:

W(0[1-9]|[1-4]\d|5[0-3])   ← matches W01–W53

Verification

$ npm test
318 passing (416ms)

All 318 existing tests pass. Four new invalid-case tests added: '2009-W00', '2009-W00-1', '2024-W00', '2020-W00-7'.

Checklist

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

Copilot AI review requested due to automatic review settings June 17, 2026 08:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2774   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2587      2587           
  Branches       656       656           
=========================================
  Hits          2587      2587           

☔ 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.

@WikiRik WikiRik requested a review from rubiin June 17, 2026 08:48
@rubiin rubiin merged commit 3d2f4b3 into validatorjs:master Jun 17, 2026
13 checks passed
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.

4 participants