-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyzerPhone.go
More file actions
58 lines (48 loc) · 1.37 KB
/
Copy pathAnalyzerPhone.go
File metadata and controls
58 lines (48 loc) · 1.37 KB
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
package main
type PhoneAnalyzer struct {
ColumnName string
Data struct {
Sanitized string `json:"sanitized"`
}
}
func (u *PhoneAnalyzer) Init(col FormatterColumn, f Formatter) ([]FormatterColumn, []FormatterIndex, error) {
u.ColumnName = col.Name
u.Data.Sanitized = "__" + col.Name + "__phone_sanitized"
return []FormatterColumn{
{Name: u.Data.Sanitized,
ForceString: true,
Tags: []string{"nullable"},
IsInvisible: true,
AlwaysGeneratedAs: CheckNull(col.Name, newSqlExpr(col.Name).OnlyNum()).String(),
Generator: u,
GeneratorData: &GeneratorData{
LinkedColumn: col.Name,
Format: "numeric",
PrimaryType: "phone_number",
Version: 1}}},
[]FormatterIndex{
{ColumnName: u.Data.Sanitized,
IndexName: "__" + col.Name + "__phone_sanitized",
Reversed: false}},
nil
}
func (u *PhoneAnalyzer) Analyze(row *map[string]*string) error {
if v, e := (*row)[u.ColumnName]; e && v != nil {
sanitized := OnlyNum(*v)
(*row)[u.Data.Sanitized] = &sanitized
}
return nil
}
func (u *PhoneAnalyzer) GetGeneratorInfo() GeneratorInfo {
return GeneratorInfo{
Name: "phone_analyzer",
VersionString: "1.0.0",
VersionId: 0x010000,
}
}
func (u *PhoneAnalyzer) GetAnalyzerData() any {
return u.Data
}
func (u *PhoneAnalyzer) GetAnalyzerType() int {
return ANALYZER_PHONE
}