rafaelrabaco/yii2-validator

Validações de documentos do Brasil e Portugal

Installs: 830

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.1 2017-08-11 18:41 UTC

This package is not auto-updated.

Last update: 2024-11-10 02:08:14 UTC


README

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 CircleCI Minimum PHP Version Latest Stable Version Total Downloads

Installation

The preferred way to install this extension is through composer.

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

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()]
		];
	}
}