🇧🇷 CPF validation in Go
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adds examples to the docs

+34 -1
+34 -1
cpf_test.go
··· 1 1 package cpf 2 2 3 - import "testing" 3 + import ( 4 + "fmt" 5 + "testing" 6 + ) 4 7 5 8 func TestMask(t *testing.T) { 6 9 for _, tc := range []struct { ··· 40 43 } 41 44 } 42 45 } 46 + 47 + func ExampleIsValid_validUnmasked() { 48 + fmt.Println(IsValid("23858488135")) 49 + // Output: true 50 + } 51 + 52 + func ExampleIsValid_validMasked() { 53 + fmt.Println(IsValid("238.584.881-35")) 54 + // Output: true 55 + } 56 + 57 + func ExampleIsValid_invalid() { 58 + fmt.Println(IsValid("111.111.111-11")) 59 + // Output: false 60 + } 61 + 62 + func ExampleMask_valid() { 63 + fmt.Println(Mask("11111111111")) 64 + // Output: 111.111.111-11 65 + } 66 + 67 + func ExampleMask_invalid() { 68 + fmt.Println(Mask("42")) 69 + // Output: 42 70 + } 71 + 72 + func ExampleUnmask() { 73 + fmt.Println(Unmask("111.111.111-11")) 74 + // Output: 11111111111 75 + }