utilsbr/cnpj/cleaner
Values
pub fn clean_alphanumeric(cnpj: String) -> String
Uppercases the input and removes every character that is not A-Z or 0-9.
pub fn clean_auto(cnpj: String) -> String
Cleans a CNPJ string, automatically detecting and preserving the appropriate format.
For alphanumeric CNPJs, preserves letters and numbers (A-Z, 0-9) and converts to uppercase. For numeric CNPJs, preserves only numbers (0-9).
Examples
clean_auto("12.ABC.345/01DE-35") // "12ABC34501DE35"
clean_auto("84.980.771/0001-82") // "84980771000182"
pub fn format_auto(cnpj: String) -> String
Formats a cleaned 14-character CNPJ as “XX.XXX.XXX/XXXX-XX”.
The grouping is identical for numeric and alphanumeric CNPJs, so a single formatter handles both formats.
Examples
format_auto("12ABC34501DE35") // "12.ABC.345/01DE-35"
format_auto("84980771000182") // "84.980.771/0001-82"
pub fn has_letters(str: String) -> Bool