Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Pt Br Validator

Pt Br Validator Laravel Package

laravellegends/pt-br-validator

Brazilian Portuguese validation rules for Laravel, adding CPF, CNPJ, CEP, phone, and other pt-BR formats as native validators so you can validate local documents and data with simple, familiar rule strings.

View on GitHub
Deep Wiki
Context7

Uma biblioteca contendo validações de formatos Brasileiros, para o Laravel

Frequently asked questions about Pt Br Validator
How do I install laravellegends/pt-br-validator in a Laravel app?
Install it with composer require laravellegends/pt-br-validator. The package is a thin service provider registered through Laravel's package auto-discovery, so you do not need to add anything to config/app.php on modern Laravel versions. Baseline use requires no published config file and no migrations, because the package only registers validation rules and stores nothing. The rules are available immediately in $request->validate() calls and FormRequests after the install.
Which Laravel and PHP versions are supported by laravellegends/pt-br-validator?
Support is defined entirely by the illuminate/support constraint declared in each release, so check that constraint against your app's Laravel version before installing. The 13.0.0 release notes provided only a changelog diff link, so the exact PHP floor and dropped Laravel majors are not enumerated and must be confirmed from composer.json or the compare diff. A major bump in a Laravel package usually raises the PHP minimum and/or changes the supported Laravel constraint. Confirm version alignment first, since a mismatch is the most common cause of a failed install here.
What Brazilian validation rules does this package add to Laravel?
It registers Brazilian document and format rules such as CPF, CNPJ, combined CPF/CNPJ, CEP, and phone formats directly into the Validator facade. Rules are used as familiar strings inside existing validation arrays, for example 'cpf' => 'required|cpf'. Validation is algorithmic and handled entirely inside the request validation layer, with no persistence and no external service calls. Verify the rule registration surface in the release you install, because rule names and message keys can change across majors.
Can I use the CPF and CNPJ rules inside FormRequest and Rule:: objects?
Yes. The rules are registered on Laravel's Validator facade, so they work anywhere validation rules are accepted: FormRequest rules() methods, $request->validate() arrays, and Rule:: composition. They can be combined with required, nullable, and other core constraints, and errors flow through Laravel's normal message pipeline. No changes to your domain or persistence layers are needed.
Does the package accept masked CPF input like 000.000.000-00?
The provided materials do not document whether masked input with punctuation is accepted, stripped, or rejected, and the 13.0.0 release notes do not enumerate semantic changes. Strict versus masked input behavior, leading-zero handling, and repeated-digit rejection are exactly the kinds of things a major bump can alter, so verify them with fixtures rather than assuming. Build a small dataset of known-valid and known-invalid documents, including masked and unmasked variants, and run it against both 12.x and 13.0.0 to detect behavioral drift.
Is laravellegends/pt-br-validator 13.0.0 safe to use in production?
Treat 13.0.0 as unverified until you have read the full compare diff, because the release notes contain only a changelog diff link with no enumerated breaking changes, deprecations, or features. The recommended path is to keep production pinned to 12.x, create a short-lived branch with 13.0.0, and diff the rule registration surface and message keys against your current usage. Run your full test suite plus document fixtures before promoting the bump. Bundle the upgrade into a regular dependency-maintenance window rather than a feature release.
Does laravellegends/pt-br-validator support the new alphanumeric CNPJ format?
The materials provided do not confirm support for the alphanumeric CNPJ format, and it is not listed among the documented changes in 13.0.0. Because the package validates algorithmically, an alphanumeric CNPJ would require an explicit implementation change rather than working automatically. Check the source and tests of the release you are considering, and add fixtures with alphanumeric documents if your application must accept them. If support is missing, keep the numeric rule and plan a first-party or alternative validator.
How do I customize or translate the CPF and CNPJ validation error messages?
Pass a custom messages array to the validator or FormRequest, keyed by field and rule (for example 'cpf.cpf' => 'CPF inválido.'), the same way you would for built-in rules. You can also centralize pt-BR strings in a language file under resources/lang. Because the package ships its own message keys, confirm those keys against the installed release before upgrading, since a major bump could rename them. Composing rules with Rule:: objects keeps messages scoped to individual fields.
How should I test CPF and CNPJ validation in my application's test suite?
Use a fixture set of known-valid and known-invalid documents covering masked input, unmasked input, repeated-digit placeholders such as 111.111.111-11, and documents with leading zeros. Assert both pass/fail behavior and the error message keys, so semantic changes surface as test failures rather than production bugs. Run the same suite against every supported Laravel and PHP combination to mirror the package's CI matrix.
Is laravellegends/pt-br-validator actively maintained, and what are the alternatives?
The package has a very small maintainer base, so bus factor is a real consideration, and its release cadence tracks Laravel majors rather than its own roadmap. Check whether 12.x still receives patches and whether a maintained security branch exists before relying on it long term. If you need a framework-agnostic or compliance-grade document algorithm with an auditable spec trail, a first-party implementation or a maintained enterprise validator is a better fit. For most Laravel applications serving the Brazilian market it remains a low-blast-radius, easy-to-verify dependency.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect