Skip to content

fix(isVAT): align eight EU matchers with the official number structures - #2876

Open
rodrigobnogueira wants to merge 1 commit into
validatorjs:masterfrom
rodrigobnogueira:fix/isvat-eu-structure
Open

fix(isVAT): align eight EU matchers with the official number structures#2876
rodrigobnogueira wants to merge 1 commit into
validatorjs:masterfrom
rodrigobnogueira:fix/isvat-eu-structure

Conversation

@rodrigobnogueira

Copy link
Copy Markdown

Aligns eight EU matchers with the number structures the national tax authorities and the Commission's VIES table publish, and fixes Ireland, which currently rejects every number issued to a company since 2013.

Each change still accepts every form the sources describe and rejects only shapes no authority issues. The new test vectors are real registered entities, each confirmed against VIES; the placeholder vectors that had to go were structurally impossible numbers (CY123456789 ends in a digit, LT12345678901 is a length Lithuania never issues, SE…12 has a suffix Skatteverket rules out).

Code Before After Why
BE \d{10} [01]\d{9} Enterprise numbers start with 0 or 1 (the 1-series opened in Sept 2023); 2–8 begin establishment-unit numbers, which are never VAT numbers.
CY \w{9} \d{8}[A-Z] Eight digits and a letter. \w also admitted _ and letters in the digit positions.
IE \d{7}\w(W)? \d{7}[A-W][A-Z]? or \d[A-Z+*]\d{5}[A-W] Bug fix. Numbers issued since 2013 carry a second letter other than W (IE3206488LH, Stripe) and the legacy 1X23456L form is still live in VIES (IE8F52100V, ESB); both are rejected today. The check letter is modulus 23, so only AW.
LT \d{9,12} (\d{7}|\d{10})1\d Only 9- and 12-digit codes exist, and the digit before the check digit is always 1.
NL \d{9}B\d{2} \d{9}B(0[1-9]|[1-9]\d) The sub-number runs B01B99; B00 is never issued.
RO \d{2,10} [1-9]\d{1,9} No leading zero: RO19 is valid, RO019 is not.
SE \d{12} \d{10}01 Skatteverket: "the last two digits are always 01".
SI \d{8} [1-9]\d{7} Base numbers start at 1 000 000, so the first digit is never 0.

FR was checked and left as is: the official structure defines both key characters as "a letter or a digit".

References:

Validation: npm test — 323 passing.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (not applicable: no country codes added or removed)
  • Tests written
  • References provided in PR

BE, CY, LT, NL, RO, SE and SI accepted shapes no authority issues: a
Belgian number starting with 2-8, a Cypriot number ending in a digit, a
10- or 11-digit Lithuanian code, a Dutch B00 sub-number, a Romanian code
with a leading zero, a Swedish suffix other than 01, a Slovenian number
starting with 0.

IE is a bug fix rather than a tightening: the matcher rejected every
number issued to a company since 2013, which carries a second letter
other than W, and the legacy 1X23456L form that is still live in VIES.

Test vectors are real registered entities confirmed against VIES; the
placeholders that had to go were structurally impossible numbers.
@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2876   +/-   ##
=========================================
  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