2017 © Pedro PelĂĄez
 

yii-extension yii-br-validator

Provide validations and features for brazilian localization on Yii 1.1.*

image

igorsantos07/yii-br-validator

Provide validations and features for brazilian localization on Yii 1.1.*

  • Thursday, July 10, 2014
  • by igorsantos07
  • Repository
  • 2 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Yii Brazilian Validators

Superseeded by yii-br-pack Latest yii-br-pack stable version, (*1)

Yii 1.1 Extension that provides validators for Brazilian localization., (*2)

  • CPF: Cadastro de Pessoa FĂ­sica (like a Security Social Number in USA)
  • CNPJ: Cadastro Nacional de Pessoa JurĂ­dica
  • landlines: beginning with 2 and 3
  • cellphones: 9 digits or 8 digits beginning with 7, 8 or 9

Installation

The preferred way to install this extension is through Composer., (*3)

Latest Stable Version Total Downloads, (*4)

Either run this:, (*5)

php composer.phar require --prefer-dist igorsantos07/yii-br-validator:1.*

or add this to the "require" section of your composer.json file., (*6)

"igorsantos07/yii-br-validator": "1.*"

Usage

Add the rules as the following example:, (*7)

class PersonForm extends CModel {

  public $cpf;
  public $cnpj;
  public $cellphone;
  public $landline;
  public $phone;
  public $areaCode;

  // For maximum readability, you should create an alias for the validator folder :)
  // Here we are assuming you have at least an alias for your vendor folder.
  public function rules() {
    // Using short array notation but the class is PHP <5.4 compatible ;)
    return [
      // CPF validator
      ['cpf', 'vendor.igorsantos07.yii-br-validator.CpfValidator'],
      // CNPJ validator
      ['cnpj', 'vendor.igorsantos07.yii-br-validator.CnpjValidator'],
      // Cellphone-only validator, checking area code inside the field
      ['cellphone', 'vendor.igorsantos07.yii-br-validator.PhoneValidator', 'type' => PhoneValidator::TYPE_CELLPHONE],
      // Cellphone-only validator, not validating area code
      [
        'cellphone',
        'vendor.igorsantos07.yii-br-validator.PhoneValidator',
        'type'     => PhoneValidator::TYPE_CELLPHONE,
        'areaCode' => false
      ],
      // Landline-only validator
      ['landline', 'vendor.igorsantos07.yii-br-validator.PhoneValidator', 'type' => PhoneValidator::TYPE_LANDLINE],
      // Any phone validator - cellphone or landline
      ['phone', 'vendor.igorsantos07.yii-br-validator.PhoneValidator'],
      // Cellphone validator with external area code check
      [
        'cellphone',
        'vendor.igorsantos07.yii-br-validator.PhoneValidator',
        'type'              => PhoneValidator::TYPE_CELLPHONE,
        'areaCodeAttribute' => 'areaCode'
      ],
    ];
  }
}

The Versions

10/07 2014

dev-master

9999999-dev

Provide validations and features for brazilian localization on Yii 1.1.*

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

validator model yii brazil brasil phone cnpj cpf br cellphone landline

10/07 2014

v1.0.4

1.0.4.0

Provide validations and features for brazilian localization on Yii 1.1.*

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

validator model yii brazil brasil phone cnpj cpf br cellphone landline

10/07 2014

v1.0.3

1.0.3.0

Provide validations and features for brazilian localization on Yii 1.1.*

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

validator model yii brazil brasil phone cnpj cpf br cellphone landline

19/05 2014

v1.0.2

1.0.2.0

Provide validations and features for brazilian localization on Yii 1.1.*

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

validator model yii brazil brasil phone cnpj cpf br cellphone landline

17/05 2014

v1.0.1

1.0.1.0

Provide validations and features for brazilian localization on Yii 1.1.*

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

validator model yii brazil brasil phone cnpj cpf br cellphone landline

17/05 2014

v1.0.0

1.0.0.0

Provide validations and features for brazilian localization on Yii 1.1.*

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

validator model yii brazil brasil cnpj cpf br