Skip to content

fix(isVAT): validate the RO check digit - #2900

Open
vicuts wants to merge 2 commits into
validatorjs:masterfrom
vicuts:fix/isvat-ro-check-digit
Open

vicuts wants to merge 2 commits into
validatorjs:masterfrom
vicuts:fix/isvat-ro-check-digit

Conversation

@vicuts

@vicuts vicuts commented Oct 4, 2026

Copy link
Copy Markdown

isVAT(str, 'RO') only checked that the code has 2 to 10 digits, so any number of that length passed, including codes with a wrong check digit.

Romanian VAT numbers (CUI/CIF) end in a check digit. This adds the standard check, in the same style as the existing AU, CH and PT matchers:

  1. Take the digits before the check digit and left-pad them with zeros to 9 digits.
  2. Multiply them by the key 753217532 and add the products.
  3. Multiply the sum by 10 and take it modulo 11. A remainder of 10 means 0.
  4. The result must equal the check digit.

The previous valid examples 1234567890 and 12 have wrong check digits, so they move to the invalid list. RO codes with a wrong check digit that passed before are now rejected, which is the intended fix.

References

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable): no change needed, RO is already listed for isVAT and the API is the same
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov

codecov Bot commented Oct 4, 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 (e91b82e).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2900   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2608    +9     
  Branches       658       660    +2     
=========================================
+ Hits          2599      2608    +9     

☔ 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