module Burocracia::CNPJ

Overview

The CNPJ module offers methods to validate, generate and format Brazilian CNPJs.

Extended Modules

Defined in:

burocracia/cnpj.cr

Constant 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

Instance Method Detail

def format(cnpj : String) : String #

Formats a CNPJ using the pattern XX.XXX.XXX/XXXX-XX.


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

Checks whether a CNPJ is formatted correctly or not.


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


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


[View source]