-
Notifications
You must be signed in to change notification settings - Fork 0
/
redact_structs.go
80 lines (72 loc) · 1.8 KB
/
redact_structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package redact
type Redactor struct {
*matched
phone *phoneRedaction
ssn *ssnRedaction
credit *creditCardRedaction
dob *dobRedaction
email *emailRedaction
monitor monitor
maxLength int
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type phoneRedaction struct {
*matched
start int
length int
breakLength int
numericLength int
}
type ssnRedaction struct {
*matched
start int
length int
breakLength int
}
type creditCardRedaction struct {
*matched
start int
length int
isSecond bool
totalSum uint64
numBreaks int
breakType byte
numericLength int
previousNumericLength int
}
type dobRedaction struct {
*matched
start int
length int
breakLength int
numericLength int
}
type emailRedaction struct {
*matched
start int
length int
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func isNumeric(value byte) bool {
return value >= '0' && value <= '9'
}
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const (
MaxEmailLength = 254
MaxPhoneLength_WithBreaks = 14
MinPhoneLength_WithBreaks = 12
MinPhoneLength_WithNoBreaks = 10
MaxPhoneBreakLength = 3
MinPhoneBreakLength = 2
MaxSSNLength_WithBreaks = 11
MaxSSNBreakLength = 2
MaxSSNBreakPosition = 6
MinSSNBreakPosition = 3
MinDOBLength_WithBreaks = 8
MaxDOBLength_WithBreaks = 11
MaxDOBBreakLength = 2
MinCreditLength_NoBreaks = 12
MaxCreditLength_NoBreaks = 19
MaxCreditBreakLength = 4
MinCreditBreakLength = 2
)