Symfony bundle for the VATIN library

Installs: 234 863

Dependents: 0

Suggesters: 0

Security: 0

Stars: 21

Watchers: 3

Forks: 5

Open Issues: 2


2.3.0 2021-08-02 13:16 UTC

This package is auto-updated.

Last update: 2021-12-02 13:59:48 UTC


Build Status Latest Stable Version

A Symfony bundle for the VATIN library.


This library is available on Packagist:

$ composer require ddeboer/vatin-bundle

Then add the bundle to your application:

// app/AppKernel.php
public function registerBundles()
    return [
        new Ddeboer\VatinBundle\DdeboerVatinBundle(),


Validate number format

Use the validator to validate a property on your models. For instance using annotations:

use Ddeboer\VatinBundle\Validator\Constraints\Vatin;

class Company
     * @Vatin
    protected $vatNumber;

Symfony’s validator will now check whether $vatNumber has a valid VAT number format. For more information, see Symfony’s documentation.

Validate number existence

Additionally, you can check whether the VAT number is in use:

     * @Vatin(checkExistence=true)
    protected $vatNumber;

The validator will now check the VAT number against the VAT Information Exchange System (VIES) SOAP web service. This service’s availability is rather unreliable, so it’s a good idea to catch the case where it’s unreachable:

use Symfony\Component\Validator\Exception\ValidatorException;

try {
    if ($validator->isValid()) {
        // Happy flow
} catch (ValidatorException $e) {
    // VAT could not be validated because VIES service is unreachable

Using the services directly

You can also use this bundle’s services directly. Validate a VAT number’s format:

$validator = $container->get('ddeboer_vatin.vatin_validator');
$bool = $validator->isValid('NL123456789B01');

Additionally check whether the VAT number is in use:

$bool = $validator->isValid('NL123456789B01', true);

To interact with the VIES webservice:

$vies = $container->get('ddeboer_vatin.vies.client');
$checkVatResponse = $vies->checkVat('NL', '123456789B01');

More information

For more information, see the VATIN library’s documentation.