vsilva472 / brcpf
Brazilian CPF validation rule for Laravel (supports formatted and unformatted CPF)
2.0.0
2026-03-31 20:45 UTC
Requires
- php: >=8.1
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- vsilva472/phpcpf: ^1.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
README
Laravel CPF validation rule for validating Brazilian CPF numbers (formatted or unformatted).
β οΈ Breaking change
Version 2+ dropped support for Laravel 9. If you are using Laravel 9, please use version
1.0.x.
β¨ Features
- β Supports formatted and unformatted CPF
- β Laravel 10 β 13+ compatible
- β Zero configuration (auto-discovery)
- β Lightweight and dependency-free
- β Translatable validation messages
π¦ Installation
composer require vsilva472/brcpf
π Usage
Inline Validation
use Vsilva472\BrCpf\Rules\Cpf; $request->validate([ 'cpf' => ['required', new Cpf()], ]);
Form Request
use Vsilva472\BrCpf\Rules\Cpf; public function rules() { return [ 'cpf' => ['required', new Cpf()], ]; }
π Custom Error Messages
Publish the language files:
php artisan vendor:publish --tag=brcpf
Then edit:
lang/vendor/brcpf/validation.php
π§ Requirements
- PHP >= 8.1
- Laravel 10 or higher
Need support for older Laravel versions? Check: https://github.com/vsilva472/laravel-cpf
π License
MIT