module

Burocracia::CEP

The CEP module offers methods to validate, generate and format Brazilian post codes.

Constants

BLACKLIST = ["12345678", "87654321"]
FORMATTED_REGEX = /^[0-9]{5}-[0-9]{3}$/i
UNFORMATTED_REGEX = /^[0-9]{8}$/i

Instance methods

format(cep : String)

Formats a CEP using the pattern XXXXX-XXX.

Source
formatted?(cep : String)

Checks whether a CEP is formatted correctly or not.

Source
generate(format : Bool = false)

Generates a randomic valid CEP.

If you want to get a formatted new CEP, you can pass an argument to the format parameter.

Source
valid?(cep : String)

Returns whether a CEP is valid or not.

NOTE: This will not fetch the CEP in the Correios database to check the existance.

Source