module Burocracia::CPF
Overview
The CPF module offers methods to validate, generate and format Brazilian CPFs.
Extended Modules
Defined in:
burocracia/cpf.crConstant 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
-
#format(cpf : String)
Formats a CPF using the pattern
XXX.XXX.XXX-XX
. -
#formatted?(cpf : String)
Checks whether a CPF is formatted correctly or not.
-
#generate(format : Bool = false)
Generates a randomic valid CPF.
-
#valid?(cpf : String)
Returns whether a CPF is valid or not.
Instance Method Detail
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.
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.