fix(isTaxID): correct dk-DK century digit 5-8 year threshold#2819
Open
hebulin wants to merge 1 commit into
Open
fix(isTaxID): correct dk-DK century digit 5-8 year threshold#2819hebulin wants to merge 1 commit into
hebulin wants to merge 1 commit into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.