Skip to content

fix(isTaxID, isIdentityCard): accept the 2023 Finnish century signs - #2948

Open
shaurya703 wants to merge 1 commit into
validatorjs:masterfrom
shaurya703:fix/fi-hetu-century-signs
Open

shaurya703 wants to merge 1 commit into
validatorjs:masterfrom
shaurya703:fix/fi-hetu-century-signs

Conversation

@shaurya703

@shaurya703 shaurya703 commented Oct 26, 2026 •

Copy link
Copy Markdown

Since 1 January 2023 the Finnish personal identity code (henkilötunnus) can use more century signs: -, Y, X, W, V, U for people born in the 1900s and A, B, C, D, E, F for people born in the 2000s. + is still used for the 1800s. isTaxID(str, 'fi-FI') and isIdentityCard(str, 'FI') only accept -, + and A, so they reject valid codes that use the new signs:

validator.isTaxID('010594Y9021', 'fi-FI');     // false, should be true
validator.isTaxID('020502E902X', 'fi-FI');     // false, should be true
validator.isIdentityCard('010594Y9021', 'FI'); // false, should be true

Both codes have correct check characters (010594902 % 31 = 1, 020502902 % 31 = 29 -> X).

Changes:

  • isTaxID (fi-FI): the format regex now accepts [-+A-FU-Y] as the century sign. fiFiCheck maps U–Y to the 1900s along with -, so the birth date check uses the right century. For example, 290200Y1239 is still rejected because 29 Feb 1900 did not exist, and 290200A1239 (29 Feb 2000) is accepted.
  • isIdentityCard (FI): the format regex accepts the same set of signs. This validator does not check the date, so nothing else changes.

Tests: added 010594Y9021 and 020502E902X as valid cases for both validators, plus 290200A1239 (valid) and 290200Y1239 (invalid) for isTaxID and an unknown sign (G) as invalid for isIdentityCard. On master the new valid cases fail; with this change npm test passes (323 passing, 100% coverage).

Reference: https://dvv.fi/en/personal-identity-code

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

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (60ad46a).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2948   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ 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