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_cep_with_rng
Generates a Cep using an injected random source.
generate_cep_with_seed
Generates a deterministic Cep from a seed.
generate_for_region
Generates a random Cep for a given postal region (1st digit fixed).
generate_for_region_with_rng
Generates a Cep for a postal region using an injected random source.
generate_for_region_with_seed
Generates a deterministic Cep for a postal region from a seed.
generate_for_state
Generates a random Cep within the range of a given state.
generate_for_state_with_rng
Generates a Cep within a state’s official segments using an injected random source.
generate_for_state_with_seed
Generates a deterministic Cep within a state’s official segments.
is_valid
Compatibility alias for is_valid_lenient.
is_valid_lenient
Lenient validation that ignores every non-ASCII-digit character.
is_valid_strict
Strict validation - accepts #####-### or ######## only.
normalize
Normalizes a permissive CEP input by retaining only ASCII digits.
remove_symbols
Compatibility alias for normalize.