-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
matcher.go
45 lines (37 loc) · 993 Bytes
/
matcher.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
package fields
import (
"github.com/K-Phoen/sdk"
)
type Matcher func(field *sdk.FieldConfigOverride)
type FieldType string
const (
FieldTypeTime FieldType = "time"
)
// ByName matches a specific field name.
func ByName(name string) Matcher {
return func(field *sdk.FieldConfigOverride) {
field.Matcher.ID = "byName"
field.Matcher.Options = name
}
}
// ByQuery matches all fields returned by the given query.
func ByQuery(ref string) Matcher {
return func(field *sdk.FieldConfigOverride) {
field.Matcher.ID = "byFrameRefID"
field.Matcher.Options = ref
}
}
// ByRegex matches fields names using a regex.
func ByRegex(regex string) Matcher {
return func(field *sdk.FieldConfigOverride) {
field.Matcher.ID = "byRegexp"
field.Matcher.Options = regex
}
}
// ByType matches fields with a specific type.
func ByType(fieldType FieldType) Matcher {
return func(field *sdk.FieldConfigOverride) {
field.Matcher.ID = "byType"
field.Matcher.Options = string(fieldType)
}
}