module Burocracia::CEP

Overview

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

Extended Modules

Defined in:

burocracia/cep.cr

Constant Summary

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

Instance Method Summary

Instance Method Detail

def format(cep : String) #

Formats a CEP using the pattern XXXXX-XXX.


[View source]
def formatted?(cep : String) #

Checks whether a CEP is formatted correctly or not.


[View source]
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.


[View source]
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.


[View source]