Utils library for Brazilian-specific businesses.
This module is the flat facade of the library: it re-exports the domain modules' functions under suffixed names (for exampleis_valid_cpf/1 delegating to brutils_cpf:is_valid/1) so
callers can depend on a single module.
| convert_license_plate_to_mercosul/1 | Converts an old-format plate to the Mercosul pattern. |
| format_cep/1 | Formats a valid CEP for display (<<"NNNNN-NNN">>). |
| format_cnpj/1 | Formats a valid CNPJ for display (<<"XX.XXX.XXX/XXXX-XX">>). |
| format_cpf/1 | Formats a valid CPF for display (<<"XXX.XXX.XXX-XX">>). |
| format_license_plate/1 | Formats a valid license plate for display (old format gets a dash, Mercosul comes out bare; both uppercased). |
| format_passport/1 | Normalizes (uppercases, strips symbols) and formats a
passport number — the lenient counterpart to
is_valid_passport/1. |
| format_phone/1 | Formats a valid phone number for display
(<<"(DD)NNNNN-NNNN">> / <<"(DD)NNNN-NNNN">>). |
| format_pis/1 | Formats a valid PIS for display (<<"NNN.NNNNN.NN-N">>). |
| format_voter_id/1 | Formats a valid 12-digit voter id for display
(<<"NNNN NNNN NN NN">>); valid 13-digit titles are refused
rather than truncated. |
| generate_cep/0 | Generates a random CEP. |
| generate_cnpj/0 | Generates a random valid CNPJ with branch number 0001. |
| generate_cnpj/1 | Generates a random valid CNPJ with the given branch number. |
| generate_cnpj/2 | Generates a random valid CNPJ, optionally alphanumeric. |
| generate_cpf/0 | Generates a random valid CPF. |
| generate_license_plate/0 | Generates a random valid Mercosul plate. |
| generate_license_plate/1 | Generates a random valid plate in the given pattern
(<<"LLLNNNN">> or <<"LLLNLNN">>). |
| generate_passport/0 | Generates a random valid passport number. |
| generate_phone/0 | Generates a random valid phone number of a random type. |
| generate_phone/1 | Generates a random valid phone number of the given type. |
| generate_pis/0 | Generates a random valid PIS. |
| generate_voter_id/0 | Generates a random valid voter id for a title issued abroad
(federative union ZZ). |
| generate_voter_id/1 | Generates a random valid voter id for the given federative union (two-letter code, case insensitive). |
| get_format_license_plate/1 | Detects the pattern of a license plate (old_format or
mercosul). |
| is_valid_cep/1 | Returns whether the given term is a valid CEP (8 digits; no check digit exists, so validity says nothing about existence). |
| is_valid_cnh/1 | Returns whether the given term is a valid CNH (2022 layout). |
| is_valid_cnpj/1 | Returns whether the given term is a valid CNPJ. |
| is_valid_cpf/1 | Returns whether the given term is a valid CPF. |
| is_valid_license_plate/1 | Returns whether the given term is a valid license plate of either pattern (old format or Mercosul). |
| is_valid_license_plate/2 | Returns whether the given term is a valid license plate of
the given pattern (old_format or mercosul). |
| is_valid_passport/1 | Returns whether the given term is a valid passport number (2 uppercase letters + 6 digits; case-sensitive, no stripping). |
| is_valid_phone/1 | Returns whether the given term is a valid Brazilian phone number, mobile or landline. |
| is_valid_phone/2 | Returns whether the given term is a valid Brazilian phone
number of the given type (mobile or landline). |
| is_valid_pis/1 | Returns whether the given term is a valid PIS. |
| is_valid_renavam/1 | Returns whether the given term is a valid RENAVAM. |
| is_valid_voter_id/1 | Returns whether the given term is a valid voter id (título de eleitor); 12 digits, or 13 for some São Paulo / Minas Gerais titles. |
| remove_international_dialing_code/1 | Removes the Brazilian international dialing code (55) from
a phone number; see the domain module for the sharp edges. |
| remove_symbols_cep/1 | Removes the formatting symbols . and - from a CEP string. |
| remove_symbols_cnpj/1 | Removes the formatting symbols ., / and - from a CNPJ
string. |
| remove_symbols_cpf/1 | Removes the formatting symbols . and - from a CPF string. |
| remove_symbols_license_plate/1 | Removes the dash (-) from a license plate string. |
| remove_symbols_passport/1 | Removes the symbols -, . and spaces from a passport
string (case is preserved). |
| remove_symbols_phone/1 | Removes common phone punctuation: (, ), -, + and
spaces (dots are kept). |
| remove_symbols_pis/1 | Removes the formatting symbols . and - from a PIS string. |
convert_license_plate_to_mercosul(Plate::binary()) -> {ok, brutils_license_plate:plate()} | {error, invalid}
Converts an old-format plate to the Mercosul pattern.
See also: brutils_license_plate:convert_to_mercosul/1.
format_cep(Cep::binary()) -> {ok, brutils_cep:formatted_cep()} | {error, invalid}
Formats a valid CEP for display (<<"NNNNN-NNN">>).
See also: brutils_cep:format/1.
format_cnpj(Cnpj::binary()) -> {ok, brutils_cnpj:formatted_cnpj()} | {error, invalid}
Formats a valid CNPJ for display (<<"XX.XXX.XXX/XXXX-XX">>).
See also: brutils_cnpj:format/1.
format_cpf(Cpf::binary()) -> {ok, brutils_cpf:formatted_cpf()} | {error, invalid}
Formats a valid CPF for display (<<"XXX.XXX.XXX-XX">>).
See also: brutils_cpf:format/1.
format_license_plate(Plate::binary()) -> {ok, brutils_license_plate:formatted_plate()} | {error, invalid}
Formats a valid license plate for display (old format gets a dash, Mercosul comes out bare; both uppercased).
See also: brutils_license_plate:format/1.
format_passport(Passport::binary()) -> {ok, brutils_passport:passport()} | {error, invalid}
Normalizes (uppercases, strips symbols) and formats a
passport number — the lenient counterpart to
is_valid_passport/1.
See also: brutils_passport:format/1.
format_phone(Phone::binary()) -> {ok, binary()} | {error, invalid}
Formats a valid phone number for display
(<<"(DD)NNNNN-NNNN">> / <<"(DD)NNNN-NNNN">>).
See also: brutils_phone:format/1.
format_pis(Pis::binary()) -> {ok, brutils_pis:formatted_pis()} | {error, invalid}
Formats a valid PIS for display (<<"NNN.NNNNN.NN-N">>).
See also: brutils_pis:format/1.
format_voter_id(VoterId::binary()) -> {ok, brutils_voter_id:formatted_voter_id()} | {error, invalid}
Formats a valid 12-digit voter id for display
(<<"NNNN NNNN NN NN">>); valid 13-digit titles are refused
rather than truncated.
See also: brutils_voter_id:format/1.
generate_cep() -> brutils_cep:cep()
Generates a random CEP.
See also: brutils_cep:generate/0.
generate_cnpj() -> brutils_cnpj:cnpj()
Generates a random valid CNPJ with branch number 0001.
See also: brutils_cnpj:generate/0.
generate_cnpj(Branch::non_neg_integer() | binary()) -> brutils_cnpj:cnpj()
Generates a random valid CNPJ with the given branch number.
See also: brutils_cnpj:generate/1.
generate_cnpj(Branch::non_neg_integer() | binary(), Alphanumeric::boolean()) -> brutils_cnpj:cnpj()
Generates a random valid CNPJ, optionally alphanumeric.
See also: brutils_cnpj:generate/2.
generate_cpf() -> brutils_cpf:cpf()
Generates a random valid CPF.
See also: brutils_cpf:generate/0.
generate_license_plate() -> {ok, brutils_license_plate:plate()}
Generates a random valid Mercosul plate.
See also: brutils_license_plate:generate/0.
generate_license_plate(Pattern::binary()) -> {ok, brutils_license_plate:plate()} | {error, invalid}
Generates a random valid plate in the given pattern
(<<"LLLNNNN">> or <<"LLLNLNN">>).
See also: brutils_license_plate:generate/1.
generate_passport() -> brutils_passport:passport()
Generates a random valid passport number.
See also: brutils_passport:generate/0.
generate_phone() -> binary()
Generates a random valid phone number of a random type.
See also: brutils_phone:generate/0.
generate_phone(Type::brutils_phone:phone_type()) -> binary()
Generates a random valid phone number of the given type.
See also: brutils_phone:generate/1.
generate_pis() -> brutils_pis:pis()
Generates a random valid PIS.
See also: brutils_pis:generate/0.
generate_voter_id() -> {ok, brutils_voter_id:voter_id()}
Generates a random valid voter id for a title issued abroad
(federative union ZZ).
See also: brutils_voter_id:generate/0.
generate_voter_id(Uf::binary()) -> {ok, brutils_voter_id:voter_id()} | {error, invalid}
Generates a random valid voter id for the given federative union (two-letter code, case insensitive).
See also: brutils_voter_id:generate/1.
get_format_license_plate(Plate::binary()) -> {ok, brutils_license_plate:plate_type()} | {error, invalid}
Detects the pattern of a license plate (old_format or
mercosul).
See also: brutils_license_plate:get_format/1.
is_valid_cep(Cep::term()) -> boolean()
Returns whether the given term is a valid CEP (8 digits; no check digit exists, so validity says nothing about existence).
See also: brutils_cep:is_valid/1.
is_valid_cnh(Cnh::term()) -> boolean()
Returns whether the given term is a valid CNH (2022 layout). Non-digit characters are stripped before validation.
See also: brutils_cnh:is_valid/1.
is_valid_cnpj(Cnpj::term()) -> boolean()
Returns whether the given term is a valid CNPJ.
See also: brutils_cnpj:is_valid/1.
is_valid_cpf(Cpf::term()) -> boolean()
Returns whether the given term is a valid CPF.
See also: brutils_cpf:is_valid/1.
is_valid_license_plate(Plate::term()) -> boolean()
Returns whether the given term is a valid license plate of either pattern (old format or Mercosul).
See also: brutils_license_plate:is_valid/1.
is_valid_license_plate(Plate::term(), Type::brutils_license_plate:plate_type()) -> boolean()
Returns whether the given term is a valid license plate of
the given pattern (old_format or mercosul).
See also: brutils_license_plate:is_valid/2.
is_valid_passport(Passport::term()) -> boolean()
Returns whether the given term is a valid passport number (2 uppercase letters + 6 digits; case-sensitive, no stripping).
See also: brutils_passport:is_valid/1.
is_valid_phone(Phone::term()) -> boolean()
Returns whether the given term is a valid Brazilian phone number, mobile or landline.
See also: brutils_phone:is_valid/1.
is_valid_phone(Phone::term(), Type::brutils_phone:phone_type()) -> boolean()
Returns whether the given term is a valid Brazilian phone
number of the given type (mobile or landline).
See also: brutils_phone:is_valid/2.
is_valid_pis(Pis::term()) -> boolean()
Returns whether the given term is a valid PIS.
See also: brutils_pis:is_valid/1.
is_valid_renavam(Renavam::term()) -> boolean()
Returns whether the given term is a valid RENAVAM. Symbols are not stripped: the input must be digits only.
See also: brutils_renavam:is_valid/1.
is_valid_voter_id(VoterId::term()) -> boolean()
Returns whether the given term is a valid voter id (título de eleitor); 12 digits, or 13 for some São Paulo / Minas Gerais titles.
See also: brutils_voter_id:is_valid/1.
remove_international_dialing_code(Phone::binary()) -> binary()
Removes the Brazilian international dialing code (55) from
a phone number; see the domain module for the sharp edges.
See also: brutils_phone:remove_international_dialing_code/1.
remove_symbols_cep(Cep::binary()) -> binary()
Removes the formatting symbols . and - from a CEP string.
See also: brutils_cep:remove_symbols/1.
remove_symbols_cnpj(Cnpj::binary()) -> binary()
Removes the formatting symbols ., / and - from a CNPJ
string.
See also: brutils_cnpj:remove_symbols/1.
remove_symbols_cpf(Cpf::binary()) -> binary()
Removes the formatting symbols . and - from a CPF string.
See also: brutils_cpf:remove_symbols/1.
remove_symbols_license_plate(Plate::binary()) -> binary()
Removes the dash (-) from a license plate string.
See also: brutils_license_plate:remove_symbols/1.
remove_symbols_passport(Passport::binary()) -> binary()
Removes the symbols -, . and spaces from a passport
string (case is preserved).
See also: brutils_passport:remove_symbols/1.
remove_symbols_phone(Phone::binary()) -> binary()
Removes common phone punctuation: (, ), -, + and
spaces (dots are kept).
See also: brutils_phone:remove_symbols/1.
remove_symbols_pis(Pis::binary()) -> binary()
Removes the formatting symbols . and - from a PIS string.
See also: brutils_pis:remove_symbols/1.
Generated by EDoc