brdoc

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: Unlicense Imports: 2 Imported by: 15

README

BR Doc

Build Status GoDoc Go Report Card codecov

CPF, CNPJ, CEP validator for Go!

Everything in this file, but the To-do and License sections, is in brazilian portuguese.

This package is also available in gopkg.in as Nhanderu/brdoc.v1.

Descrição

BR Doc é um pacote para validação, tanto do formato quanto dos dígitos, de documentos brasileiros, como CPF, CNPJ, (e futuramente) CEP e RG. Este pacote possui apenas as funções individuais de validação. Para utilizar da integração com o govalidator, é necessário importar o pacote BR Doc Govalidator.

Uso

Principais funções:

  • func IsCPF(doc string) bool
  • func IsCNPJ(doc string) 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") //=> false
brdoc.IsCNPJ("26.637.142/0001-00") //=> false

// Inválidos por causa do formato:
brdoc.IsCPF("248 438 034 80") //=> false
brdoc.IsCNPJ("26637142-0001.58") //=> false

// Válidos:
brdoc.IsCPF("248.438.034-80") //=> true
brdoc.IsCPF("24843803480") //=> true
brdoc.IsCNPJ("26.637.142/0001-58") //=> true
brdoc.IsCNPJ("26637142000158") //=> true
To-do list
  • CPF validation
  • CNPJ validation
  • CEP validation
  • RG validation
License

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCNPJ

func IsCNPJ(doc string) bool

IsCNPJ verifies if the string is a valid CNPJ document.

func IsCPF

func IsCPF(doc string) bool

IsCPF verifies if the string is a valid CPF document.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL