PHP code example of antalaron / vat-number-validator

1. Go to this page and download the library: Download antalaron/vat-number-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

antalaron / vat-number-validator example snippets


use Antalaron\Component\VatNumberValidator\VatNumber;
use Symfony\Component\Validator\Validation;

$validator = Validation::createValidator();
$violations = $validator->validate('ATU37675002', new VatNumber());

if (0 !== count($violations)) {
    foreach ($violations as $violation) {
        echo $violation->getMessage().'<br>';
    }
}

$violations = $validator->validate('11', new VatNumber(['extraVat' => function ($number) {
    return 0 !== preg_match('/^(\d{2})$/', $number);
}]));