···1616 cnpf.IsValid("238.584.881-35")
1717 cnpf.IsValid("11222333000181")
1818 cnpf.IsValid("11.222.333/0001-81")
1919+ cnpj.IsValid("12.ABC.345/01DE-35")
2020+ cnpj.IsValid("12ABC34501DE35")
19212022 // these return false
2123 cnpf.IsValid("111.111.111-11")
···2628 cnpf.IsValid("AB.CDE.FGH/IJKL-MN")
2729 cnpf.IsValid("123")
28302929- // these returns 11111111111 and 11111111111111
3131+ // these return 11111111111, 11111111111111 and 12ABC34501DE35
3032 cnpf.Unmask("111.111.111-11")
3133 cnpf.Unmask("11.111.111/1111-11")
3434+ cnpj.Unmask("12.ABC.345/01DE-35")
32353333- // this returns 111.111.111-11 and 11.111.111/1111-11
3636+ // this return 111.111.111-11, 11.111.111/1111-11 and 12.ABC.345/01DE-35
3437 cnpf.Mask("11111111111")
3538 cnpf.Mask("11111111111111")
3939+ cnpj.Mask("12ABC34501DE35")
3640}
3741```
4242+> [!IMPORTANT]
4343+> Starting in July 2026 [the CNPJ number will be alphanumeric](https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico). This package **already supports the new format**. If you **do not** want to support the new format, tag this package to [`v0.0.1`](https://github.com/cuducos/go-cnpf/releases/tag/v0.0.1).
38443945Based on [Go CPF](https://github.com/cuducos/go-cpf) and [Go CNPJ](https://github.com/cuducos/go-cnpj) ❤️
+7-6
cnpf.go
···11package cnpf
2233import (
44- cpf "github.com/cuducos/go-cpf"
55- cnpj "github.com/cuducos/go-cnpj"
44+ cnpj "github.com/cuducos/go-cnpj"
55+ cpf "github.com/cuducos/go-cpf"
66)
7788-//Unmask removes any non-digit (numeric) from a CPF or CNPJ number
88+// Unmask removes any non-alphanumeric character (like punctuation) from a CPF
99+// or CNPJ number
910func Unmask(n string) string {
1010- return cpf.Unmask(n)
1111+ return cnpj.Unmask(n)
1112}
12131313-//Mask returns the CPF or CNPJ number formatted
1414+// Mask returns the CPF or CNPJ number formatted
1415func Mask(n string) string {
1516 u := Unmask(n)
1617 if len(u) == 11 {
···2223 return n
2324}
24252525-//IsValid checks whether a number is a valid CPF or CNPJ number
2626+// IsValid checks whether a number is a valid CPF or CNPJ number
2627func IsValid(n string) bool {
2728 return cpf.IsValid(n) || cnpj.IsValid(n)
2829}