Skip to content

fix(isTaxID): reduce pl-PL and lv-LV check digit modulo 10#2827

Open
gaoflow wants to merge 1 commit into
validatorjs:masterfrom
gaoflow:fix-taxid-modulus-check-digit-reduction
Open

fix(isTaxID): reduce pl-PL and lv-LV check digit modulo 10#2827
gaoflow wants to merge 1 commit into
validatorjs:masterfrom
gaoflow:fix-taxid-modulus-check-digit-reduction

Conversation

@gaoflow

@gaoflow gaoflow commented Jul 26, 2026

Copy link
Copy Markdown

plPlCheck (PESEL) and lvLvCheck compare a raw modulus result against a single digit without reducing it back into 0–9, so on the boundary residue the predicate demands a check digit of 10 and none of the ten digits can satisfy it. Every valid PESEL and every valid pre-2017 Latvian personal code whose check digit is 0 is rejected — about 10% and 9% of those two ID spaces.

validator.isTaxID('02070800090', 'pl-PL'); // false <- valid PESEL
validator.isTaxID('01011000010', 'lv-LV'); // false <- valid personas kods
// and so are all nine other check digits for those two bodies

The fix is the same % 10 reduction #1529 applied to elGrCheck. I checked the rest of the file for the same boundary: bg-BG, dk-DK, es-AR, et-EE, pt-BR, pt-PT, ro-RO, uk-UA and the ISO 7064 helper already map the out-of-range residue back to a digit, and hu-HU, nl-NL and sl-SI reject it because those numbers genuinely are not issued — these two were the only ones missing it. The new fixtures cover each century branch of both functions and fail without the src/ change; npm test passes with it.

plPlCheck (PESEL) and lvLvCheck both compare a raw modulus result against a
single digit without reducing it back into 0-9, so on the boundary residue the
comparison demands a check digit of 10 and no digit can satisfy it. Every PESEL
and every pre-2017 Latvian personal code whose check digit is 0 is rejected.

Same reduction validatorjs#1529 applied to elGrCheck.
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2827   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2600      2600           
  Branches       659       659           
=========================================
  Hits          2600      2600           

☔ 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