Skip to content

fix(isTaxID): correct dk-DK century digit 5-8 year threshold#2819

Open
hebulin wants to merge 1 commit into
validatorjs:masterfrom
hebulin:master
Open

fix(isTaxID): correct dk-DK century digit 5-8 year threshold#2819
hebulin wants to merge 1 commit into
validatorjs:masterfrom
hebulin:master

Conversation

@hebulin

@hebulin hebulin commented Jul 14, 2026

Copy link
Copy Markdown

This fixes issue #2818 where Danish CPR numbers (CPR-numre) with century digits 5-8 and years 37-57 were incorrectly rejected.

The default case in dkDkCheck handles century digits 5-8. The original implementation used a threshold of 37/58 (matching the century digit 4/9 case), which was incorrect. For digits 5-8, the year split should be at 57/58: years 00-57 ? 2000s, years 58-99 ? 1800s.

This fix changes the threshold from if (year < 37) / else if (year > 58) to a clean if (year < 58) / else split, correctly mapping years 0-57 to the 2000s and years 58-99 to the 1800s.

For Danish CPR numbers (dk-DK), when the century digit is 5, 6, 7, or 8,
the correct century mapping is:
- year 00-57 → 2000s
- year 58-99 → 1800s

The previous code incorrectly used the same thresholds as the 4/9 case
(year < 37 / year > 58), leaving a gap for years 37-58 that caused
otherwise valid CPR numbers to be rejected.

Fixes validatorjs#2818
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2819   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2587      2585    -2     
  Branches       656       655    -1     
=========================================
- Hits          2587      2585    -2     

☔ 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