gc
github.com/cuducos/go-cnpf
go get github.com/cuducos/go-cnpf
gc

github.com/cuducos/go-cnpf

🇧🇷 CPF and CNPJ validation in Go

by Eduardo Cuducos

v0.0.1 (see all)License:BSD-3-Clause
go get github.com/cuducos/go-cnpf
Readme

Go CNPF Tests GoDoc Go version

A Go module to validate CPF and CNPJ numbers (Brazilian people and companies unique identifier for the Federal Revenue).

The pseudo-acronym CNPF is a sort of tong-twister and a common typo when developers discuss the implementation of objects that could hold either a CPF or a CNPJ numbers.

package main

import "github.com/cuducos/go-cnpf"


func main() {
    // these return true
    cnpf.IsValid("23858488135")
    cnpf.IsValid("238.584.881-35")
    cnpf.IsValid("11222333000181")
    cnpf.IsValid("11.222.333/0001-81")

    // these return false
    cnpf.IsValid("111.111.111-11")
    cnpf.IsValid("11.111.111/1111-11")
    cnpf.IsValid("123.456.769/01")
    cnpf.IsValid("12.345.678 9012-34")
    cnpf.IsValid("ABC.DEF.GHI-JK")
    cnpf.IsValid("AB.CDE.FGH/IJKL-MN")
    cnpf.IsValid("123")

    // these returns 11111111111 and 11111111111111
    cnpf.Unmask("111.111.111-11")
    cnpf.Unmask("11.111.111/1111-11")

    // this returns 111.111.111-11 and 11.111.111/1111-11
    cnpf.Mask("11111111111")
    cnpf.Mask("11111111111111") 
}

Based on Go CPF and Go CNPJ ❤️

GitHub Stars

12

LAST COMMIT

2yrs ago

MAINTAINERS

0

CONTRIBUTORS

3

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v0.0.2-0.20200822042032-cbfd378acf27
1yr ago
v0.0.2-0.20200414235403-17e776bafbb9
2yrs ago
v0.0.1
2yrs ago
No alternatives found
No tutorials found
Add a tutorial