Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv2.

brdoc

packagemodule
v1.1.2Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2018 License:UnlicenseImports:4Imported by:11

Details

Repository

github.com/paemuri/brdoc

Links

README

BR Doc

Build StatusGoDocGo Report Cardcodecov

CPF, CNPJ and CEP validator for Go!

Everything in this file, but theLicense section, is in brazilian portuguese.

This package is also available in gopkg.in asNhanderu/brdoc.v1.

Descrição

BR Doc é um pacote para validação, tanto do formato quanto dos dígitos, de documentos brasileiros, como CPF, CNPJ, CEP e (futuramente) RG.

Uso

Principais funções:

  • func IsCPF(doc string) bool
  • func IsCNPJ(doc string) bool
  • func IsCEP(doc string, ufs ...FederativeUnit) bool

Exemplo de valores válidos e inválidos:

// Inválidos por causa da inconsistência do dígito:brdoc.IsCPF("248.438.034-99") //=> falsebrdoc.IsCNPJ("26.637.142/0001-00") //=> false// Inválidos por causa do formato:brdoc.IsCPF("248 438 034 80") //=> falsebrdoc.IsCNPJ("26637142-0001.58") //=> falsebrdoc.IsCEP("01 001.001") //=> false// Inválidos por causa da UF:brdoc.IsCEP("01001-001", brdoc.RJ) //=> false// Válidos:brdoc.IsCPF("248.438.034-80") //=> truebrdoc.IsCPF("24843803480") //=> truebrdoc.IsCNPJ("26.637.142/0001-58") //=> truebrdoc.IsCNPJ("26637142000158") //=> truebrdoc.IsCEP("01001-001", brdoc.SP) //=> truebrdoc.IsCEP("01001001", brdoc.SP) //=> true

To-do list

  • validação de CPF
  • validação de CNPJ
  • validação de CEP
  • validação de RG

Validação de RG não foi implementado porque cada estado tem as suas regrase eu não estou com vontade de terminar isso. 💤

License

This project code is in the public domain. See theLICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcIsCEPadded inv1.1.0

func IsCEP(docstring, ufs ...FederativeUnit)bool

IsCEP verifies if `doc` is a valid CEP.`ufs` represents the possible Federative Units theCEP should matches.If none is provided, it validates the document forany state/district.

funcIsCNPJ

func IsCNPJ(docstring)bool

IsCNPJ verifies if the string is a valid CNPJdocument.

funcIsCPF

func IsCPF(docstring)bool

IsCPF verifies if the string is a valid CPFdocument.

funcValidateCEPFormatadded inv1.1.0

func ValidateCEPFormat(docstring)bool

ValidateCEPFormat verifies if the CEP has a validformat.

funcValidateCNPJFormatadded inv1.1.1

func ValidateCNPJFormat(docstring)bool

ValidateCNPJFormat verifies if the CNPJ has avalid format.

funcValidateCPFFormatadded inv1.1.1

func ValidateCPFFormat(docstring)bool

ValidateCPFFormat verifies if the CPF has avalid format.

Types

typeFederativeUnitadded inv1.1.0

type FederativeUnituint8

FederativeUnit represents a state or a district in Brazil.

const (ACFederativeUnit =iotaALAPAMBACEDFESGOMAMTMSMGPAPBPRPEPIRJRNRSRORRSCSPSETO)

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp