Documentation ¶
Index ¶
- Variables
- func IsCEP(doc string, ufs ...FederativeUnit) bool
- func IsCNH(doc string) bool
- func IsCNPJ(doc string) bool
- func IsCNS(doc string) bool
- func IsCPF(doc string) bool
- func IsMercosulPlate(doc string) bool
- func IsNationalPlate(doc string) bool
- func IsPIS(doc string) bool
- func IsPlate(doc string) bool
- func IsRENAVAM(doc string) bool
- func IsRG(doc string, uf FederativeUnit) (isValid bool, err error)
- type FederativeUnit
Constants ¶
This section is empty.
Variables ¶
var ( CPFRegexp = regexp.MustCompile(`^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$`) CNPJRegexp = regexp.MustCompile(`^\d{2}\.?\d{3}\.?\d{3}\/?(:?\d{3}[1-9]|\d{2}[1-9]\d|\d[1-9]\d{2}|[1-9]\d{3})-?\d{2}$`) )
Regexp pattern for CPF and CNPJ.
var ( NationalPlateRegexp = regexp.MustCompile(`^[A-Z]{3}-?\d{4}$`) MercosulPlateRegexp = regexp.MustCompile(`^[A-Z]{3}\d[A-Z]\d{2}$`) )
Regexp pattern for license plates patterns.
var (
CEPRegexp = regexp.MustCompile(`^\d{5}-?\d{3}$`)
)
Regexp pattern for CEP.
var (
CNSRegexp = regexp.MustCompile(`^([12]\d{2}\s?\d{4}\s?\d{4}\s?00[01]\d|[789]\d{2}\s?\d{4}\s?\d{4}\s?\d{4})$`)
)
Regexp pattern for CNS.
var (
PISRegexp = regexp.MustCompile(`^\d{3}\.?\d{3,5}\.?\d{2,4}-?\d$`)
)
Regexp pattern for PIS.
Functions ¶
func IsCEP ¶
func IsCEP(doc string, ufs ...FederativeUnit) bool
IsCEP verifies if `doc` is a valid CEP. `ufs` represents the possible Federative Units the CEP should matches. If none is provided, it validates the document for any state/district.
func IsMercosulPlate ¶
IsMercosulPlate verifies if the given string is a valid license plate in the new Mercosul format.
func IsNationalPlate ¶
IsNationalPlate verifies if the given string is a valid license plate in the old national format.
func IsPlate ¶
IsPlate verifies if the given string is a valid license plate.IsPlate It can be either in the old national format or the new Mercosul one.
Types ¶
type FederativeUnit ¶
type FederativeUnit uint8
FederativeUnit represents a state or a district in Brazil.
const ( AC FederativeUnit = iota AL AP AM BA CE DF ES GO MA MT MS MG PA PB PR PE PI RJ RN RS RO RR SC SP SE TO )
Federative unit for CEP validation.