From 406f0045e4bb526d36330e7892cb64d7f5214330 Mon Sep 17 00:00:00 2001 From: waw666waw666 <184799977+waw666waw666@users.noreply.github.com> Date: Tue, 1 Dec 2026 13:12:46 +0000 Subject: [PATCH] fix(isVAT): reject non-dot separators in BR VAT numbers 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 #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 #2977, leaving BR as the last one. Escape the four dots so only the documented dotted forms validate. --- src/lib/isVAT.js | 2 +- test/validators.test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/isVAT.js b/src/lib/isVAT.js index f561d3ae1..864158ee5 100644 --- a/src/lib/isVAT.js +++ b/src/lib/isVAT.js @@ -111,7 +111,7 @@ export const vatMatchers = { */ AR: str => /^(AR)?\d{11}$/.test(str), BO: str => /^(BO)?\d{7}$/.test(str), - BR: str => /^(BR)?((\d{2}.\d{3}.\d{3}\/\d{4}-\d{2})|(\d{3}.\d{3}.\d{3}-\d{2}))$/.test(str), + BR: str => /^(BR)?((\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2})|(\d{3}\.\d{3}\.\d{3}-\d{2}))$/.test(str), CL: str => /^(CL)?\d{8}-\d{1}$/.test(str), CO: str => /^(CO)?\d{10}$/.test(str), CR: str => /^(CR)?\d{9,12}$/.test(str), diff --git a/test/validators.test.js b/test/validators.test.js index 98d2a12ff..17c391c14 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -15973,6 +15973,10 @@ describe('Validators', () => { invalid: [ 'BR 12.345.678/9012-34', '12345678901234', + '12,345,678/9012-34', + '12a345b678/9012-34', + '123,456,789-01', + '123a456b789-01', ], }); test({