This package is deprecated and will not be maintained.
This library validate VAT numbers by using regular expressions and the VIES (VAT Information Exchange System) service.
composer require florowebdevelopment/vat-validator
use Florowebdevelopment\VatValidator\VatValidator;
$oVatValidator = new VatValidator;
$oVatValidator->validate('NL821783981B01'); // true
if ($oVatValidator->isValid()) {
$aMetaData = $oVatValidator->getMetaData();
/*
array(
"name" => "FLORO WEBDEVELOPMENT B.V.",
"address" => "WESTBLAAK 00180 3012KN ROTTERDAM"
)
*/
}
When strict is set to FALSE, the VAT number validation returns TRUE if the VIES service is not available (CURL timeout or SoapFault).
$oVatValidator->setStrict(false); // default = true
We suggest that you cache the valid VAT numbers in your application to prevent multiple requests to the VIES service.