davidvandertuijn/vat-validator

1.1 2024-10-02 13:56 UTC

This package is auto-updated.

Last update: 2024-12-02 15:01:55 UTC


README

Total Downloads Latest Stable Version License

VAT Validator

This VAT Number Validation library allows users to verify VAT numbers with high accuracy by leveraging both regular expressions and the VIES (VAT Information Exchange System) service. This dual-layer validation ensures that VAT numbers are correctly formatted and legally valid within the European Union.

"Buy Me A Coffee"

Install

composer require davidvandertuijn/vat-validator

Usage

use Davidvandertuijn\VatValidator\Validator as VatValidator;
$vatValidator = new VatValidator;

$vatValidator->validate('NL821783981B01'); // true

if ($vatValidator->isValid()) {
    $metaData = $vatValidator->getMetaData();
}
[
    "name" => "FLORO WEBDEVELOPMENT B.V.",
    "address" => "WESTBLAAK 00180 3012KN ROTTERDAM"
]

Strict

In this VAT Number Validation library, when strict mode is set to FALSE, the validation process is more flexible, especially in scenarios where the VIES (VAT Information Exchange System) service is temporarily unavailable. In such cases, the validation will return TRUE, allowing the workflow to continue without disruption due to service timeouts or SOAP errors.

$vatValidator->setStrict(false); // default = true

Cache

To optimize the validation process and reduce the dependency on the VIES (VAT Information Exchange System) service, we recommend caching valid VAT numbers within your application. This approach minimizes repeated requests to the VIES service and improves overall performance.