PHPackages                             rafaelrabaco/yii2-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. rafaelrabaco/yii2-validator

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

rafaelrabaco/yii2-validator
===========================

Validações de documentos do Brasil e Portugal

1.0.1(8y ago)1972BSD-3-ClausePHP

Since Aug 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/rafaelrabaco/yii2-validator)[ Packagist](https://packagist.org/packages/rafaelrabaco/yii2-validator)[ RSS](/packages/rafaelrabaco-yii2-validator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Yii 2 Validator
===============

[](#yii-2-validator)

Yii2 Extension that provide validations and features for Brazilian and Portugal localization

- CPF: Cadastro de pessoa física **(BR)**
- CNPJ: Cadastro nacional de pessoa jurídica **(BR)**
- CEI: Cadastro específico no INSS **(BR)**
- NIF: Número de identificação fiscal **(PT)**

[![Yii2](https://camo.githubusercontent.com/b8013fa3e5a1c8176343636d0a0a9344e33f38a7375ef689234e713c84715c0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c61742d737175617265266d61784167653d33363030)](http://www.yiiframework.com/)[![CircleCI](https://camo.githubusercontent.com/80d0c8ef6fe2820ee3e327d4aa9e442be8b3dbc887b01b191f955bdb6d7f9688/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f6769746875622f72616661656c72616261636f2f796969322d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://circleci.com/gh/rafaelrabaco/yii2-validator)[![Minimum PHP Version](https://camo.githubusercontent.com/c0e5505cb428cc9143e322e5784d3bad4cc1e2983e39cc27f2f09eae925db00a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e302d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![Latest Stable Version](https://camo.githubusercontent.com/7a573a4bf9e1953b08c98c2c4ed31e9e233e4bd97c1b73d2f6a17bee524fe984/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72616661656c72616261636f2f796969322d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rafaelrabaco/yii2-validator)[![Total Downloads](https://camo.githubusercontent.com/cecf2a498b6e932eadf708ba17468bf2a96a7d6d512166a316b12baed412d04d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72616661656c72616261636f2f796969322d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rafaelrabaco/yii2-validator)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist rafaelrabaco/yii2-validator "*"

```

or add

```
"rafaelrabaco/yii2-validator": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Add the rules as the following example

```
use Yii;
use yii\base\Model;
use rafaelrabaco\validator\CpfValidator;
use rafaelrabaco\validator\CnpjValidator;
use rafaelrabaco\validator\CeiValidator;
use rafaelrabaco\validator\NifValidator;

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

	/**
	 * @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()]
			// nif validator
			['nif', NifValidator::className()]
		];
	}
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity64

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3194d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/530d71b51a0c7135ca7fa3e8fc956644697c93786e2830fa56d5e150f3eca8ad?d=identicon)[rafaelrabaco](/maintainers/rafaelrabaco)

---

Tags

validatormodelyiibrbrazilNIFcpfcnpjbrasilportugalpt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rafaelrabaco-yii2-validator/health.svg)

```
[![Health](https://phpackages.com/badges/rafaelrabaco-yii2-validator/health.svg)](https://phpackages.com/packages/rafaelrabaco-yii2-validator)
```

###  Alternatives

[yiibr/yii2-br-validator

Provide validations and features for brazilian localization

14103.2k4](/packages/yiibr-yii2-br-validator)[bissolli/validador-cpf-cnpj

Classe em PHP para validação de CPF e CNPJ.

2089.0k](/packages/bissolli-validador-cpf-cnpj)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
