Skip to content
pubscout

cpf_cnpj_validator

2.0.0, released 6 years ago by an unverified publisher

Validate, format, strip and generate Brazilian CPF and CNPJ numbers.

WASM-ready
$ flutter pub add cpf_cnpj_validator
Source repository

What it does

Provides utility classes to validate, format, strip, and generate Brazilian CPF and CNPJ identification numbers. It supports both raw and formatted string inputs with customizable stripping behavior.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to validate user input for Brazilian CPF or CNPJ documents in forms.
  • You need to format raw CPF/CNPJ strings or strip formatting characters.
  • You need to generate random valid CPF or CNPJ numbers for testing or placeholders.

Skip it when

  • Your application does not deal with Brazilian tax or identification numbers.

Strengths

  • Simple and straightforward static API methods.
  • Supports both validation and generation of CPF and CNPJ.
  • Null safety supported in version 2.0.0.

Weaknesses

  • Limited in scope strictly to Brazilian CPF/CNPJ numbers.
  • No built-in UI form field widgets provided out of the box.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:cpf_cnpj_validator/cpf_validator.dart';

bool isValid = CPFValidator.isValid("334.616.710-02");
String formatted = CPFValidator.format("33461671002");

Alternatives

Packages that do the same job and could replace cpf_cnpj_validator.