Documentation
¶
Overview ¶
Package br provides utility functions and methods for dealing with Brazilian documents.
This package includes validators, generators and formatters for various Brazilian documents, such as CPF and CNPJ, as well as functions for handling Brazilian postal codes (CEP).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCNH = errors.New("br: invalid cnh")
ErrInvalidCNH is an error returned when an invalid CNH is encountered.
var ErrInvalidCNPJ = errors.New("br: invalid cnpj")
ErrInvalidCNPJ is an error returned when an invalid CNPJ is encountered.
var ErrInvalidCNS = errors.New("br: invalid cns")
ErrInvalidCNS is an error returned when an invalid CNS is encountered.
var ErrInvalidCPF = errors.New("br: invalid cpf")
ErrInvalidCPF is an error returned when an invalid CPF is encountered.
var ErrInvalidPlate = errors.New("br: invalid license plate")
ErrInvalidPlate is an error returned when an invalid license plate is encountered.
Functions ¶
This section is empty.
Types ¶
type CNH ¶
type CNH string
CNH represents a Brazilian driver's license number.
func NewCNH ¶
NewCNH creates a new CNH instance from a string representation.
It verifies the CNH's validity using checksum digits.
type CNPJ ¶
type CNPJ string
CNPJ represents a Brazilian CNPJ.
func NewCNPJ ¶
NewCNPJ creates a new CNPJ instance from a string representation.
It verifies the CNPJ's validity using checksum digits.
func (CNPJ) AlphaNumerical ¶
func (CNPJ) IsValid ¶
IsValid checks whether the provided CNPJ is valid based on its checksum digits.
type CNS ¶
type CNS string
CNS represents a Brazilian CNS.
func NewCNS ¶
NewCNS creates a new CNS instance from a string representation.
It verifies the CNS's validity using checksum digits.
type CPF ¶
type CPF string
CPF represents a Brazilian CPF.
func NewCPF ¶
NewCPF creates a new CPF instance from a string representation.
It verifies the CPF's validity using checksum digits.
type Plate ¶
type Plate string
Plate represents a Brazilian vehicle license plate.
func GeneratePlate ¶
func GeneratePlate() Plate
GeneratePlate generates a pseudo-random valid Plate.
func (Plate) IsValid ¶
IsValid checks whether the provided license plate is valid based on specific formatting rules.
IsValid will return true if the plate if either a MercoSul or a Brazilian type plate.
The formats accepted are: XXXXXXX, XXX-XXXX, XXX.XXXX