Skip to content

fix(isVAT): reject non-dot separators in BR VAT numbers - #2980

Open
waw666waw666 wants to merge 1 commit into
validatorjs:masterfrom
waw666waw666:fix/isvat-br-dot-separators
Open

waw666waw666 wants to merge 1 commit into
validatorjs:masterfrom
waw666waw666:fix/isvat-br-dot-separators

Conversation

@waw666waw666

Copy link
Copy Markdown

The BR VAT matcher used unescaped dots as separators in the CNPJ
and CPF patterns, so any character was accepted where a literal dot
is required:

isVAT('12,345,678/9012-34', 'BR') // true, should be false
isVAT('12a345b678/9012-34', 'BR') // true, should be false
isVAT('123,456,789-01', 'BR')     // true, should be false

This is the sibling gap left by #2814, which rejected stray commas
in the DO and VE matchers: the ID matcher had the same
unescaped-dot flaw and was already fixed by #2977, leaving BR as
the last one. This escapes the four dots so only the documented
dotted forms validate.

Testing: added the four inputs above to the BR invalid cases in
should validate VAT numbers (fails before, passes after); full
Mocha suite 323 passing with no new failures; npm run lint clean.

The BR CNPJ/CPF patterns used unescaped dots as separators, so any
character (comma, letter, space) was accepted where a literal dot is
required, e.g. isVAT('12,345,678/9012-34', 'BR') returned true. This
is the sibling gap left by validatorjs#2814, which fixed stray commas in the DO
and VE matchers: the ID matcher had the same unescaped-dot flaw and
was already fixed by open PR validatorjs#2977, leaving BR as the last one.

Escape the four dots so only the documented dotted forms validate.
@codecov

codecov Bot commented Dec 1, 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 (406f004).

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