Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Validator
'SI' => '\d{8}',
'SK' => '\d{10}',
'SM' => '\d{5}',
'XI' => '(\d{3} ?\d{4} ?\d{2}( ?\d{3})?|[A-Z\d]{5})',
];

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public function testValidateVatNumberFormat(): void
'SE123456789012',
'SI12345678',
'SK1234567890',
'XI123456789',
'XI123 4567 89',
'XI123456789111',
'XI123 4567 89 111',
'XIHZ6AB',
];

$validator = new Validator();
Expand Down Expand Up @@ -96,6 +101,7 @@ public function testValidateVatNumberFormat(): void
'SE12345678901',
'SI1234567',
'SK123456789',
'XI12345678',

// valid number but with prefix
'invalid_prefix_GB999999973',
Expand All @@ -104,13 +110,15 @@ public function testValidateVatNumberFormat(): void
'invalid_prefix_BE0123456789',
'invalid_prefix_MT12345678',
'invalid_prefix_LT123456789',
'invalid_prefix_XI123456789',

// valid number but with suffix
'IE1234567X_invalid_suffix',
'ESB1234567C_invalid_suffix',
'BE0123456789_invalid_suffix',
'MT12345678_invalid_suffix',
'LT123456789_invalid_suffix',
'XI123456789_invalid_suffix',
];

foreach ($invalid as $format) {
Expand Down