1. Go to this page and download the library: Download igorsantos07/yii-br-pack library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
igorsantos07 / yii-br-pack example snippets
class PersonForm extends CModel {
public $name;
public $cpf;
public $cnpj;
public $cellphone;
public $landline;
public $phone;
public $areaCode;
public $card_number;
public $card_cvv;
public $card_expiry;
public function rules() {
// Using short array notation but the class is PHP <5.4 compatible ;)
return [
// CPF validator
['cpf', 'BrPack\Validator\Cpf'],
// CNPJ validator
['cnpj', 'BrPack\Validator\Cnpj'],
// Cellphone-only validator, checking area code inside the field
['cellphone', 'BrPack\Validator\Phone', 'type' => PhoneValidator::TYPE_CELLPHONE],
// Cellphone-only validator, not validating area code
[
'cellphone',
'BrPack\Validator\Phone',
'type' => BrPack\Validator\Phone::TYPE_CELLPHONE,
'areaCode' => false
],
// Landline-only validator
['landline', 'BrPack\Validator\Phone', 'type' => BrPack\Validator\Phone::TYPE_LANDLINE],
// Any phone validator - cellphone or landline
['phone', 'BrPack\Validator\Phone'],
// Cellphone validator with external area code check
[
'cellphone',
'BrPack\Validator\Phone',
'type' => BrPack\Validator\Phone::TYPE_CELLPHONE,
'areaCodeAttribute' => 'areaCode'
],
];
}
}