-
Notifications
You must be signed in to change notification settings - Fork 5
/
options.go
63 lines (47 loc) · 1.33 KB
/
options.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
package sanitize
// Option represents an optional setting for the sanitizer library
type Option interface {
id() string
value() interface{}
}
// OptionTagName allows users to use custom tag names for the structs
type OptionTagName struct {
Value string
}
var _ Option = OptionTagName{}
const optionTagNameID = "tag-name"
func (o OptionTagName) id() string {
return optionTagNameID
}
func (o OptionTagName) value() interface{} {
return o.Value
}
// OptionDateFormat allows users to specify what date formats are accepted
// as input and what is expected as output. You can choose to force the date
// to be parsed in a different format, or keep the original format
type OptionDateFormat struct {
Input []string
KeepFormat bool
Output string
}
var _ Option = OptionDateFormat{}
const optionDateFormatID = "date-format"
func (o OptionDateFormat) id() string {
return optionDateFormatID
}
func (o OptionDateFormat) value() interface{} {
return o
}
// OptionSanitizerFunc allows users to use custom sanitizer functions
type OptionSanitizerFunc struct {
Name string
Sanitizer SanitizerFunc
}
var _ Option = OptionSanitizerFunc{}
const optionSanitizerFuncID = "sanitizer-func"
func (o OptionSanitizerFunc) id() string {
return optionSanitizerFuncID
}
func (o OptionSanitizerFunc) value() interface{} {
return o.Sanitizer
}