module Burocracia::CPF

Overview

The CPF module offers methods to validate, generate and format Brazilian CPFs.

Extended Modules

Defined in:

burocracia/cpf.cr

Constant Summary

BLACKLIST = ["12345678901", "1235678999", "12345678900"]
FORMATTED_REGEX = /^[0-9]{3}.[0-9]{3}.[0-9]{3}-[0-9]{2}$/i
UNFORMATTED_REGEX = /^[0-9]{11}$/i

Instance Method Summary

Instance Method Detail

def format(cpf : String) #

Formats a CPF using the pattern XXX.XXX.XXX-XX.


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

Checks whether a CPF is formatted correctly or not.


[View source]
def generate(format : Bool = false) #

Generates a randomic valid CPF.

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


[View source]
def valid?(cpf : String) #

Returns whether a CPF is valid or not.

NOTE This will not fetch the CPF in the Receita Federal database to check the existance.


[View source]