florowebdevelopment/vat-validator

This package is abandoned and no longer maintained. The author suggests using the https://github.com/davidvandertuijn/vat-validator package instead.

VAT Validator

3.0 2020-12-28 16:04 UTC

This package is auto-updated.

Last update: 2024-10-02 14:04:35 UTC


README

This package is deprecated and will not be maintained.

VAT Validator

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.