ideup / extra-validator-bundle
Symfony2 Validators for Spain Postcodes and Personal identifications
Installs: 7 909
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 9
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3
This package is not auto-updated.
Last update: 2024-11-05 08:56:18 UTC
README
This package contains a set of useful validators and asserts to use in your projects.
Included Asserts/Validators
- DNI (DNI/NIF documents)
- Phone (phone numbers, by regular expresions)
- MobilePhone (mobile phone numbers)
- PrefixedPhone (phone numbers with international prefix)
How to include ExtraValidator
In your composer.json
"require": { "ideup/extra-validator-bundle": "dev-master" }
... and in your AppKernel.php
file:
<?php public function registerBundles() { $bundles = array( ... new Ideup\ExtraValidatorBundle\IdeupExtraValidatorBundle(), ); }
How to use ExtraValidator in your Forms/Entities
<?php namespace Acme\AcmeDemoBundle\Entity; use Ideup\ExtraValidatorBundle\Validator as ExtraAssert; class AcmeEntity { /** * @ExtraAssert\MobilePhone(message="Your mobile phone number is not valid") */ protected $phone; ... }
You can use both Assert
and ExtraAssert
validators in your entities/forms:
<?php namespace Acme\AcmeDemoBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; use Ideup\ExtraValidatorBundle\Validator as ExtraAssert; class AcmeEntity { /** * @Assert\NotBlank(message="You have to input a phone number") * @ExtraAssert\MobilePhone(message="Your mobile phone number is not valid") */ protected $phone; ... }
ExtraAssert
validators do not modify symfony's regular asserts, we just add a bunch of useful set of new validators to
make our lives easy!
Authors
- javiacei
- Moisés Maciá