vsilva472/brcpf

Brazilian CPF validation rule for Laravel (supports formatted and unformatted CPF)

Maintainers

Package info

github.com/vsilva472/brcpf

pkg:composer/vsilva472/brcpf

Statistics

Installs: 22

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2026-03-31 20:45 UTC

This package is auto-updated.

Last update: 2026-03-31 20:58:17 UTC


README

Laravel CPF validation rule for validating Brazilian CPF numbers (formatted or unformatted).

Latest Version Downloads License

πŸ‡§πŸ‡· Leia em portuguΓͺs

⚠️ 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