ricardonavarrom / vatin-validator-bundle
A Symfony bundle for for validating VAT identification numbers (VATINs).
Installs: 31
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.5.9
- incenteev/composer-parameter-handler: ^2.0
- ricardonavarrom/vatin-validator: 1.*
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- symfony/console: >=2.8,<4.0
- symfony/monolog-bundle: ^2.4
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: ^4.8
- satooshi/php-coveralls: ^1.0
- sensio/generator-bundle: ^3.0
- symfony/phpunit-bridge: ^2.7
README
A Symfony bundle for for validating VAT identification numbers (VATINs) based on VATINValidator PHP library.
Installation
This bundle is available on Packagist.
You can install this bundle using composer
$ composer require ricardonavarrom/vatin-validator-bundle
or add the package to your composer.json file directly.
After you have installed the package, you just need to add the bundle to your AppKernel.php file:
// in AppKernel::registerBundles() $bundles = array( // ... new ricardonavarrom\VATINValidatorBundle\VATINValidatorBundle(), // ... );
Configuration
VATINValidatorBundle requires no initial configuration to get you started.
Basic usage
The configured validator is available as ricardonavarrom.vatin_validator service. You must assign a valid locale (view availables locales section).
$locale = 'es'; $vatin = '56475114V'; $validator = $container->get('ricardonavarrom.vatin_validator'); $vatinIsValid = $validator->validate($vatin, $locale);
Another option is to use a located validator service as ricardonavarrom.vatin_validator.es (view availables locales section).
$vatin = '56475114V'; $locatedValidator = $container->get('ricardonavarrom.vatin_validator.es'); $vatinIsValid = $locatedValidator->validate($vatin);
Availables locales
Constraints
VATINValidatorBundle provides the following constraints:
// src/AppBundle/Entity/Customer.php namespace AppBundle\Entity; use ricardonavarrom\VATINValidatorBundle\Validator\Constraints\VATINEsConstraint; class Customer { /** * @VATINEsConstraint( * allowLowerCase = false, * validationModality = "NIF" * ) */ private $vatin; }