validar_brasileiro library
Brazilian document and form validators for Dart and Flutter.
Every type documents its CheckKind. isValid means the value is
well-formed and passes the published checksum or format table — it does
not mean a government registry issued it.
Classes
- Boleto
- Brazilian boleto (cobrança 47/44 or arrecadação 48).
- Cartao
- Payment-card PAN (ISO/IEC 7812 Luhn).
- Cep
- Brazilian postal code.
- Certidao
- Civil-registry certificate number (Provimento CNJ 46/2015).
- Cnh
- CNH registro number (11 digits).
- Cnpj
- Brazilian CNPJ, numeric or alphanumeric (IN RFB 2.229/2024).
- Cns
- Cartão Nacional de Saúde (CNS / Cartão SUS).
- Cpf
- Brazilian CPF (Cadastro de Pessoas Físicas).
- EmailAddress
- Form-grade email check (not a full RFC 5322 parser).
- IbanBr
-
Brazilian IBAN (
BR, 29 characters). - Ie
- Inscrição Estadual (ICMS).
- NfeChave
- NF-e / NFC-e access key (44 digits).
-
ParseFail<
T> - Failed parse.
-
ParseOk<
T> - Successful parse.
-
ParseResult<
T> - Outcome of inspect on a document type.
- Phone
- Brazilian telephone number (Anatel numbering plan).
- Pis
- PIS / PASEP / NIS / NIT (same NIT modulo 11).
- PixKey
- A syntactically valid PIX key.
- Placa
- Brazilian vehicle plate (legacy and Mercosul).
- ProcessoCnj
- Número único de processo judicial (CNJ Resolução 65/2008).
- RENAVAM vehicle identifier.
- Rg
- Registro Geral (RG).
- TituloEleitor
- Título de eleitor (TSE).
Enums
- CheckKind
- How a value is checked by this package.
- ParseIssue
-
Why a document parser rejected
input. - PixKeyType
- PIX key syntax (Banco Central DICT types).
- Uf
- Brazilian federative unit (26 states + DF).
Functions
-
all(
Iterable< FieldValidator> rules) → FieldValidator -
Runs
rulesin order and returns the first error. -
boleto(
{String message = 'Boleto inválido'}) → FieldValidator - Boleto validator.
-
cartao(
{String message = 'Cartão inválido'}) → FieldValidator - Payment-card Luhn validator.
-
cep(
{String message = 'CEP inválido'}) → FieldValidator - CEP format validator.
-
certidao(
{String message = 'Certidão inválida'}) → FieldValidator - Civil certificate validator.
-
cnh(
{String message = 'CNH inválida'}) → FieldValidator - CNH checksum validator.
-
cnpj(
{String message = 'CNPJ inválido'}) → FieldValidator - CNPJ checksum validator (numeric and alphanumeric).
-
cnpjCharValue(
int codeUnit) → int -
ASCII(codeUnit) - 48used by alphanumeric CNPJ (IN RFB 2.229/2024). -
cnpjCharValues(
String canonical) → List< int> - Maps CNPJ base characters to their DV calculation values.
-
cns(
{String message = 'CNS inválido'}) → FieldValidator - CNS checksum validator.
-
collectAlphanumericUpper(
String input) → String? - Collects ASCII letters and digits, skipping mask characters.
-
collectDigits(
String input) → String? - Collects ASCII digits, skipping mask characters.
-
cpf(
{String message = 'CPF inválido'}) → FieldValidator - CPF checksum validator.
-
email(
{String message = 'E-mail inválido'}) → FieldValidator - Email format validator.
-
equalsTo(
String other, {String message = 'Valores não conferem'}) → FieldValidator -
Requires
valueto equalother. -
ibanBr(
{String message = 'IBAN inválido'}) → FieldValidator - Brazilian IBAN validator.
-
ie(
Uf uf, {String message = 'Inscrição estadual inválida'}) → FieldValidator -
Inscrição Estadual validator for
uf. -
isMaskChar(
int codeUnit) → bool -
Whether
codeUnitis a formatting character that identifiers ignore. -
isPixEmail(
String input) → bool - PIX DICT emails: form-grade, lowercase, at most 77 characters.
-
isRepeatedDigitString(
String digits) → bool -
Whether every character in
digitsis the same ASCII digit. -
maxLength(
int n, {String? message}) → FieldValidator - Maximum length.
-
maxValue(
num n, {String? message}) → FieldValidator - Maximum numeric value.
-
minLength(
int n, {String? message}) → FieldValidator - Minimum trimmed length.
-
minValue(
num n, {String? message}) → FieldValidator - Minimum numeric value.
-
nfeChave(
{String message = 'Chave NF-e inválida'}) → FieldValidator - NF-e access key validator.
-
phone(
{String message = 'Telefone inválido'}) → FieldValidator - Brazilian phone format validator.
-
pis(
{String message = 'PIS inválido'}) → FieldValidator - PIS/PASEP/NIS/NIT checksum validator.
-
pix(
{String message = 'Chave PIX inválida'}) → FieldValidator - PIX key syntax validator.
-
placa(
{String message = 'Placa inválida'}) → FieldValidator - Vehicle plate format validator.
-
processoCnj(
{String message = 'Processo inválido'}) → FieldValidator - CNJ process number validator.
- RENAVAM checksum validator.
-
required(
{String message = 'Campo obrigatório'}) → FieldValidator - Rejects null/blank values.
-
requiredWhen(
bool condition, {String message = 'Campo obrigatório'}) → FieldValidator -
Applies required only when
conditionis true. -
rg(
Uf uf, {String message = 'RG inválido'}) → FieldValidator -
RG validator for
uf. -
tituloEleitor(
{String message = 'Título de eleitor inválido'}) → FieldValidator - Título de eleitor checksum validator.
Typedefs
- FieldValidator = String? Function(String? value)
-
Flutter
FormField/TextFormFieldstyle validator.