Laravel CPF validation rule for validating Brazilian CPF numbers (formatted or unformatted).
⚠️ Breaking changeVersion 2+ dropped support for Laravel 9. If you are using Laravel 9, please use version
1.0.x.
- ✅ Supports formatted and unformatted CPF
- ✅ Laravel 10 → 13+ compatible
- ✅ Zero configuration (auto-discovery)
- ✅ Lightweight and dependency-free
- ✅ Translatable validation messages
composer require vsilva472/brcpfuse Vsilva472\BrCpf\Rules\Cpf;
$request->validate([
'cpf' => ['required', new Cpf()],
]);use Vsilva472\BrCpf\Rules\Cpf;
public function rules()
{
return [
'cpf' => ['required', new Cpf()],
];
}Publish the language files:
php artisan vendor:publish --tag=brcpfThen edit:
lang/vendor/brcpf/validation.php
- PHP >= 8.1
- Laravel 10 or higher
Need support for older Laravel versions? Check: https://github.com/vsilva472/laravel-cpf
MIT