An Yii2 validator for EU VAT numbers
based on https://github.com/herdani/vat-validation
The
- Validate a VAT number
- Retrieve information like the name or the address of the company
The data is extracted from a European Commission webservice
It ONLY works for European Union countries
PHP with Soap enabled
composer require elvenpath/yii2-eu-vatvalidator
public function rules()
{
return [
[
'vat',
EuVatValidator::className(),
'country_code' => $this->country_code,
],
];
}
You can also populate the model with the company name and address got from the EU database
public function rules()
{
return [
[
'vat',
EuVatValidator::className(),
'country_code' => $this->country_code,
'populate_model' => true,
'model_name_attribute' => 'name',
'model_address_attribute' => 'address'
],
];
}
Take a look at http://ec.europa.eu/taxation_customs/vies/viesdisc.do to know when/how you're allowed to use this service and his information