diff --git a/src/VatNumberValidator.php b/src/VatNumberValidator.php index 0699cf7..9f53720 100644 --- a/src/VatNumberValidator.php +++ b/src/VatNumberValidator.php @@ -90,9 +90,12 @@ public function validate($value, Constraint $constraint) return; } + // Use only the expressions for the given country code + $schemes = preg_grep('/^\/\^\('.preg_quote(substr($value, 0, 2), '/').'/', $this->schemes); + // Check the string against the regular expressions for all types of // VAT numbers - foreach ($this->schemes as $scheme) { + foreach ($schemes as $scheme) { // Have we recognised the VAT number? if (0 !== preg_match($scheme, $value, $match)) { // Yes - we have: