Tricks

Brazilian CNPJ Validation

Oct 15, 2022
Leandro C. Ferreira
Form builder, Integration

Installation

To get started with laravellegends/pt-br-validator, you can install it using the command:

composer require laravellegends/pt-br-validator

Validation

You can validate the input by passing cnpj validation rule:

use Filament\Forms\Components\TextInput;
 
//cnpj
TextInput::make('cnpj')
->rule('cnpj')
->maxLength(18)
->mask(fn (TextInput\Mask $mask) => $mask->pattern('00.000.000/0000-00')),

No comments yet…