module Burocracia::CNPJ
Overview
The CNPJ module offers methods to validate, generate and format Brazilian CNPJs.
Extended Modules
Defined in:
burocracia/cnpj.crConstant Summary
-
BLACKLIST =
["12345678912345", "12345678900000", "12345678999999", "12345678911111"]
-
FORMATTED_REGEX =
/^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/i
-
UNFORMATTED_REGEX =
/^[0-9]{14}$/i
Instance Method Summary
-
#format(cnpj : String) : String
Formats a CNPJ using the pattern
XX.XXX.XXX/XXXX-XX
. -
#formatted?(cnpj : String) : Bool
Checks whether a CNPJ is formatted correctly or not.
-
#generate(format : Bool = false) : String
Generates a randomic valid CNPJ.
-
#valid?(cnpj : String) : Bool
Returns whether a CNPJ is valid or not.
Instance Method Detail
def generate(format : Bool = false) : String
#
Generates a randomic valid CNPJ.
If you want to get a formatted new CNPJ, you can pass an argument to the format parameter.
def valid?(cnpj : String) : Bool
#
Returns whether a CNPJ is valid or not.
NOTE This will not fetch the CNPJ in the Receita Federal database to check the existance.