Skip to content

fix(isVAT): accept Spanish digit controls - #2849

Open
ANONYMOUSZED-beep wants to merge 1 commit into
validatorjs:masterfrom
ANONYMOUSZED-beep:fix/spanish-vat-control-digits
Open

fix(isVAT): accept Spanish digit controls#2849
ANONYMOUSZED-beep wants to merge 1 commit into
validatorjs:masterfrom
ANONYMOUSZED-beep:fix/spanish-vat-control-digits

Conversation

@ANONYMOUSZED-beep

Copy link
Copy Markdown

Fixes #2846.

The Spanish VAT matcher currently requires a trailing letter, so it rejects valid legal-entity NIFs whose control character is a digit. It also accepts unassigned entity prefixes and mismatched prefix/control forms.

This change groups Spanish legal-entity prefixes by their permitted control type:

  • digit: A, B, E, H
  • letter: N, P, Q, R, S, W
  • digit or letter: C, D, F, G, J, U, V

Regression coverage includes prefixed and unprefixed digit-control values, letter-control and dual-control forms, plus mismatched controls, unassigned prefixes, and malformed length.

References:

Validation:

  • npx mocha --require @babel/register --reporter dot --recursive --grep "validate VAT numbers"
  • npx eslint src/lib/isVAT.js test/validators.test.js
  • npm test — 323 passing; build and full ESLint included

AI assistance was used to prepare and validate this focused change; the final diff and test results were reviewed before submission.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (not applicable; no API contract change)
  • Tests written
  • References provided

Signed-off-by: Arun <ANONYMOUSZED-beep@users.noreply.github.com>
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

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

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

isVAT rejects valid Spanish VAT numbers whose control character is a digit

2 participants