Provide validations and features for brazilian localization

Installs: 73 836

Dependents: 7

Suggesters: 0

Security: 0

Stars: 14

Watchers: 6

Forks: 9

Open Issues: 1


1.1.1 2020-06-19 12:11 UTC

This package is auto-updated.

Last update: 2024-04-19 20:09:28 UTC


Yii2 Extension that provide validators and features for brazilian localization

  • CPF: Cadastro de pessoa física (like a Security Social Numeber in USA)
  • CNPJ: Cadastro nacional de pessoa jurídica
  • CEI: Cadastro específico no INSS (número de matrícula)

Yii2 Latest Stable Version Build Status Scrutinizer Code Quality Code Coverage Total Downloads


The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiibr/yii2-br-validator "*"

or add

"yiibr/yii2-br-validator": "*"

to the require section of your composer.json file.


Add the rules as the following example

use Yii;
use yii\base\Model;
use yiibr\brvalidator\CpfValidator;
use yiibr\brvalidator\CnpjValidator;
use yiibr\brvalidator\CeiValidator;

class PersonForm extends Model
	public $name;
	public $cpf;
	public $cnpj;
	public $cei;

	 * @return array the validation rules.
	public function rules()
		return [
			// name is required
			['name', 'required'],
			// cpf validator
			['cpf', CpfValidator::className()],
			// cnpj validator
			['cnpj', CnpjValidator::className()],
			// cei validator
			['cei', CeiValidator::className()]