module Burocracia::CEP
Overview
The CEP module offers methods to validate, generate and format Brazilian post codes.
Extended Modules
Defined in:
burocracia/cep.crConstant Summary
-
BLACKLIST =
["12345678", "87654321"]
-
FORMATTED_REGEX =
/^[0-9]{5}-[0-9]{3}$/i
-
UNFORMATTED_REGEX =
/^[0-9]{8}$/i
Instance Method Summary
-
#format(cep : String)
Formats a CEP using the pattern
XXXXX-XXX
. -
#formatted?(cep : String)
Checks whether a CEP is formatted correctly or not.
-
#generate(format : Bool = false)
Generates a randomic valid CEP.
-
#valid?(cep : String)
Returns whether a CEP is valid or not.
Instance Method Detail
def 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.
def 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.