ibericode / vat

PHP library for dealing with European VAT
https://packagist.org/packages/ibericode/vat
MIT License
425 stars 61 forks source link

[bug] Fix spanish vat regex, which previously allowed invalid vat ending overflow #25

Closed Swop closed 4 years ago

Swop commented 4 years ago

Since the Spanish VAT pattern allows multiple combinaisons (with the regex pipe "|"), it looks like the regex accept any string if only the beginning of the string is matching any of the possible patterns.

This means that the validator will consider those examples as valid:

but also those ones:

Here's a patch to avoid this problem.

dannyvankooten commented 4 years ago

Awesome @Swop, thank you for catching it! Merged and released in 2.0.2 of the package.

Swop commented 4 years ago

Cool. Thanks!