Skip to content

Commit f788d91

Browse files
Merge branch 'wiegandj-add-validation-for-northern-ireland'
2 parents 81501e5 + f1bc328 commit f788d91

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Validator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Validator
4141
'SE' => '\d{12}',
4242
'SI' => '\d{8}',
4343
'SK' => '\d{10}',
44+
'XI' => '(\d{3} ?\d{4} ?\d{2}( ?\d{3})?|[A-Z\d]{5})',
4445
];
4546

4647
/**

tests/ValidatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function testValidateVatNumberFormat(): void
5353
'SE123456789012',
5454
'SI12345678',
5555
'SK1234567890',
56+
'XI123456789',
57+
'XI123 4567 89',
58+
'XI123456789111',
59+
'XI123 4567 89 111',
60+
'XIHZ6AB',
5661
];
5762

5863
$validator = new Validator();
@@ -94,20 +99,23 @@ public function testValidateVatNumberFormat(): void
9499
'SE12345678901',
95100
'SI1234567',
96101
'SK123456789',
102+
'XI12345678',
97103

98104
// valid number but with prefix
99105
'invalid_prefix_IE1234567X',
100106
'invalid_prefix_ESB1234567C',
101107
'invalid_prefix_BE0123456789',
102108
'invalid_prefix_MT12345678',
103109
'invalid_prefix_LT123456789',
110+
'invalid_prefix_XI123456789',
104111

105112
// valid number but with suffix
106113
'IE1234567X_invalid_suffix',
107114
'ESB1234567C_invalid_suffix',
108115
'BE0123456789_invalid_suffix',
109116
'MT12345678_invalid_suffix',
110117
'LT123456789_invalid_suffix',
118+
'XI123456789_invalid_suffix',
111119
];
112120

113121
foreach ($invalid as $format) {

0 commit comments

Comments
 (0)