| Package Data | |
|---|---|
| Maintainer Username: | danielebarbaro |
| Maintainer Contact: | barbaro.daniele@gmail.com (Daniele Barbaro) |
| Package Create Date: | 2019-02-05 |
| Package Last Update: | 2025-10-17 |
| Home Page: | http://daniele.barbaro.online |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-02 03:00:24 |
| Package Statistics | |
|---|---|
| Total Downloads: | 300,085 |
| Monthly Downloads: | 12,028 |
| Daily Downloads: | 150 |
| Total Stars: | 37 |
| Total Watchers: | 1 |
| Total Forks: | 15 |
| Total Open Issues: | 1 |
laravel-vat-eu-validator is a package inspired from vat.php to validate a VAT number for businesses based in Europe.
You can install the package via composer:
composer require danielebarbaro/laravel-vat-eu-validator
The package will automatically register itself.
use Danielebarbaro\LaravelVatEuValidator\Facades\VatValidatorFacade as VatValidator;
// Check VAT format and VIES existence
VatValidator::validate('IT12345');
// Check VAT format
VatValidator::validateFormat('IT12345678901');
// Check VAT existence
VatValidator::validateExistence('IT12345678901');
The package registers two new validation rules.
vat_number
The field under validation must be a valid and existing VAT number.
vat_number_exist
The field under validation check id is an existing VAT number.
vat_number_format
The field under validation must be a valid VAT number.
use Illuminate\Http\Request;
class Controller {
public function foo(Request $request)
{
$request->validate([
'bar_field' => [new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber()],
]);
$request->validate([
'bar_field' => [new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumberExist()],
]);
$request->validate([
'bar_field' => [new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumberFormat()],
]);
}
}
Alternatively, you can also use the Rule directly.
use Illuminate\Http\Request;
use Danielebarbaro\LaravelVatEuValidator\Rules;
class Controller {
public function foo(Request $request)
{
$request->validate([
'bar_field' => [ new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber() ],
'bar_field' => [ new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumberExist() ],
'bar_field' => [ new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumberFormat() ],
]);
}
}
or
use Illuminate\Http\Request;
use Danielebarbaro\LaravelVatEuValidator\Rules;
class Controller {
public function foo(Request $request)
{
$request->validate([
'bar_field' => [
new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber(),
new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumberExist(),
new \Danielebarbaro\LaravelVatEuValidator\Rules\VatNumberFormat(),
],
]);
}
}
or
use Illuminate\Http\Request;
use Danielebarbaro\LaravelVatEuValidator\Rules;
class Controller {
public function foo(Request $request)
{
$request->validate([
'bar_field' => [
'vat_number',
'vat_number_format',
'vat_number_exist',
],
]);
}
}
Most of the displayed strings are defined in the vatEuValidator::validation translation files. The package ships with a few supported locales, but if yours is not yet included we would greatly appreciate a PR.
If not already published, you can edit or fill the translation files using php artisan vendor:publish --tag=laravel-vat-eu-validator-lang, this will copy our translation files to your app's vendor/laravelVatEuValidator "lang" path.
composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email barbaro.daniele@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.