Skip to main content

Module cep

Module cep 

Source
Expand description

CEP (Código de Endereçamento Postal) - validation, formatting and generation.

Brazilian postal codes are 8 digits with no check digit. Validation is structural (8 numeric characters, optionally formatted as XXXXX-XXX) plus optional region/state lookup by range.

Structs§

Cep
A validated CEP stored as 8 ASCII bytes.

Enums§

CepError
PostalRegion
Postal region mapped by the first digit of a CEP.

Functions§

format_cep
Formats as #####-###, or None if not 8 digits.
generate
Generates a random valid CEP as an 8-digit string.
generate_cep
Generates a random valid Cep.
generate_for_region
Generates a random Cep for a given postal region (1st digit fixed).
generate_for_state
Generates a random Cep within the range of a given state.
is_valid
is_valid_strict
Strict validation - accepts #####-### or ######## only.
remove_symbols