Skip to content

Commit 3c85708

Browse files
authored
Fix: correct French VAT (FR) validation regex and add tests (#2584)
1 parent eee525c commit 3c85708

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/lib/isVAT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const vatMatchers = {
6060
DK: str => /^(DK)?\d{8}$/.test(str),
6161
EE: str => /^(EE)?\d{9}$/.test(str),
6262
FI: str => /^(FI)?\d{8}$/.test(str),
63-
FR: str => /^(FR)?\w{2}\d{9}$/.test(str),
63+
FR: str => /^(FR)([A-Z0-9]{2}\d{9})$/.test(str),
6464
DE: str => /^(DE)?\d{9}$/.test(str),
6565
EL: str => /^(EL)?\d{9}$/.test(str),
6666
HU: str => /^(HU)?\d{8}$/.test(str),

test/validators.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15055,11 +15055,18 @@ describe('Validators', () => {
1505515055
args: ['FR'],
1505615056
valid: [
1505715057
'FRAA123456789',
15058-
'AA123456789',
15058+
'FR83404833048',
15059+
'FR40123456789',
15060+
'FRA1123456789',
15061+
'FR1A123456789',
1505915062
],
1506015063
invalid: [
1506115064
'FR AA123456789',
1506215065
'123456789',
15066+
'FRAA123456789A',
15067+
'FR123456789',
15068+
'FR 83404833048',
15069+
'FRaa123456789',
1506315070
],
1506415071
});
1506515072
test({

0 commit comments

Comments
 (0)