stonkeep/cpf-cnpj
Validate, format, and generate Brazilian CPF and CNPJ documents in Laravel. Includes ready-to-use validation rules, mask and formatting helpers, and clean value objects so you can handle tax IDs consistently across your application.
What the package is. stonkeep/cpf-cnpj is a single-purpose Laravel Nova field that renders an input for Brazilian CPF (individual) and CNPJ (company) tax identifiers, presumably applying input masking and check-digit validation on top of Nova's base Field class. Its entire functional surface is likely one or two PHP classes plus a Vue component.
Architecture fit. Adoption is gated on a hard prerequisite: the application must already run Laravel Nova, a paid, closed-source admin panel with per-project licensing. If the product's back office is built on Filament, Livewire, Inertia, or a bespoke Blade admin, this package is architecturally irrelevant — there is no partial-fit path. Even within Nova, the value is narrow: it improves one form input. It contributes nothing to API validation, imports, queue jobs, or domain modeling, so CPF/CNPJ rules would still need to be enforced server-side elsewhere (FormRequests, model casts, DB constraints).
Integration feasibility. Mechanically trivial — composer require, register the field in a Nova resource, done. The real feasibility question is version compatibility: Nova 4 and Nova 5 have meaningfully different field APIs and asset pipelines, and a package at zero stars/zero dependents has almost certainly been tested against exactly one Nova major version. There is no CI badge, changelog, or release cadence to inspect.
Technical risk — high, concentrated in three areas:
Key questions for the maintainer / spike:
rules() call) or only as a JS mask?Verdict. Do not adopt as a dependency of record. Either fork it and own the ~150 lines, or implement the field in-house and pair it with a maintained validation library for server-side rules.
Stack fit. Requirements are Laravel + Nova + a supported PHP version. The package addresses presentation and input hygiene only; it must be paired with a server-side validator. The reliable choice is a mature PT-BR validation package (e.g. laravellegends/pt-br-validator, which supplies cpf and cnpj rules) rather than relying on the field's client-side behavior. Persist as CHAR(14) (digits only) with a formatter/cast for display.
Migration path. Greenfield: register the field on the relevant Nova resources, add the validation rule to the corresponding FormRequest or Nova rules(), and add a model accessor for formatted output. Brownfield with existing CPF/CNPJ columns: run a one-off audit/normalization job before enabling validation, because legacy rows likely contain a mix of masked and unmasked values — enabling strict validation on a resource with dirty data produces save failures that look like regressions to users.
Compatibility and sequencing.
nova-fields package so upgrades are under your control.Maintenance. The dominant cost is not the package itself but the unowned upgrade risk: every Nova and PHP upgrade becomes a manual check against a dependency nobody maintains. Forking internalizes this and reduces it to near zero, at the cost of ~1–2 days of engineering plus ongoing ownership of a small file. Leaving it as an external dependency trades that upfront cost for recurring, unbounded risk at upgrade time.
Support. No vendor, no SLA, no security disclosure process. A vulnerability in the field would surface through your own review, not an advisory. For an admin-panel input this is a low-severity exposure (authenticated back-office users only), but it should be recorded in the third-party inventory with a "no upstream support" flag.
Scaling. Negligible performance impact — it is a form input. No query, cache, or throughput considerations. The scaling concern is organizational: one more micro-dependency multiplies the surface a platform team must audit across many Laravel services.
Failure modes.
Ramp-up. Essentially zero for a Laravel developer — it's a Nova field registered like any other. The genuine ramp-up is domain knowledge: CPF/CNPJ check-digit semantics, the raw-vs-formatted storage convention, and the 2026 alphanumeric change. Budget that as product/ops context, not engineering time.
Recommendation. Treat as a reference implementation, not a dependency. Allocate ~2 days to fork or rebuild the field, own the validation server-side with a maintained rules package, and standardize on digits-only storage with display formatting. The package is a reasonable starting point precisely because it is small enough to absorb.
How can I help you explore Laravel packages today?