florowebdevelopment/vat-validator

3.0 2020-12-28 16:04 UTC

This package is auto-updated.

Last update: 2024-05-28 23:35:25 UTC


README

Total Downloads Latest Stable Version License StyleCI

This library validate VAT numbers by using regular expressions and the VIES (VAT Information Exchange System) service.

Install

composer require florowebdevelopment/vat-validator

Usage

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"
    )
    */
}

Strict (optional)

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

Comments

We suggest that you cache the valid VAT numbers in your application to prevent multiple requests to the VIES service.