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
Requires
- yiisoft/yii2: *
Requires (Dev)
- phpunit/phpunit: 5.7.*
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)
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()] ]; } }