Skip to content

Commit

Permalink
Throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jan 29, 2024
1 parent e5b758c commit e440942
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ public function hasSupportedCountryPrefix(string $vatNumber): bool
* Validate a VAT number format. This does not check whether the VAT number was really issued.
*
* @param string $vatNumber
* @param bool $skipIfUnsupported
*
* @return boolean
*/
public function validateVatNumberFormat(string $vatNumber, bool $skipIfUnsupported = false): bool
public function validateVatNumberFormat(string $vatNumber): bool
{
if ($vatNumber === '') {
return false;
Expand All @@ -113,7 +112,7 @@ public function validateVatNumberFormat(string $vatNumber, bool $skipIfUnsupport
$number = substr($vatNumber, 2);

if (! isset($this->patterns[$country])) {
return $skipIfUnsupported;
throw new \InvalidArgumentException('The vat country prefix is not supported.');
}

return preg_match('/^' . $this->patterns[$country] . '$/', $number) > 0;
Expand Down
8 changes: 0 additions & 8 deletions tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ public function testValidateVatNumberFormat()
'SI1234567',
'SK123456789',

// valid number but with prefix
'invalid_prefix_GB999999973',
'invalid_prefix_IE1234567X',
'invalid_prefix_ESB1234567C',
'invalid_prefix_BE0123456789',
'invalid_prefix_MT12345678',
'invalid_prefix_LT123456789',

// valid number but with suffix
'IE1234567X_invalid_suffix',
'ESB1234567C_invalid_suffix',
Expand Down

0 comments on commit e440942

Please sign in to comment.