Skip to content

Symfony2 Validators for Spain Postcodes and Personal identifications

Notifications You must be signed in to change notification settings

javiacei/ExtraValidatorBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ExtraValidator bundle for Symfony2

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á

About

Symfony2 Validators for Spain Postcodes and Personal identifications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages