laravel-br-validation maintained by lumensistemas
Description
Laravel integration for lumensistemas/br-validation: Rule classes and named validators for Brazilian identifiers (CPF, CNPJ, PIS, Título de Eleitor, CNH, Renavam, placa, CNS, chave PIX, CEP, telefone, boleto, NF-e).
Author
Last update
2026/05/17 14:51
(dev-main)
License
Downloads
0
Tags
laravel-br-validation
Laravel integration for lumensistemas/br-validation.
Ships Illuminate\Contracts\Validation\ValidationRule classes
and matching string-named rules (cpf, cnpj, pis, …) for
every Brazilian identifier the underlying library covers.
Requirements
- PHP 8.3 or newer
- Laravel 12 or 13
ext-mbstring
Installation
composer require lumensistemas/laravel-br-validation
The service provider is auto-discovered. Publish the translations if you want to override them:
php artisan vendor:publish --tag=laravel-br-validation-lang
Usage
As string-named rules
$request->validate([
'cpf' => ['required', 'cpf'],
'cnpj' => ['required', 'cnpj'],
'pis' => ['nullable', 'pis'],
'titulo_eleitor' => ['nullable', 'titulo_eleitor'],
'cnh' => ['nullable', 'cnh'],
'renavam' => ['nullable', 'renavam'],
'placa' => ['nullable', 'placa'],
'cns' => ['nullable', 'cns'],
'chave_pix' => ['nullable', 'pix'],
'cep' => ['required', 'cep'],
'telefone' => ['required', 'phone_br'],
'boleto' => ['required', 'boleto'],
'nfe' => ['required', 'nfe'],
]);
As Rule classes
use LumenSistemas\LaravelBrValidation\Rules\Cpf;
use LumenSistemas\LaravelBrValidation\Rules\Pix;
$request->validate([
'cpf' => ['required', new Cpf()],
'chave' => ['required', new Pix(types: ['email', 'phone'])],
]);
Pix accepts an optional types array to restrict accepted
chave PIX types (cpf, cnpj, email, phone, evp); when
omitted, all five types are accepted.
Translations
Messages ship in en and pt_BR. Override per locale by
publishing the language files:
php artisan vendor:publish --tag=laravel-br-validation-lang
Development
composer install
composer test
License
MIT. See LICENSE.