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
|
// Code generated by "string-enumer -t ShippingLevel -t Title --text -o ./ship_gen.go ."; DO NOT EDIT.
package lulu
import (
"fmt"
)
// validShippingLevelValues contains a map of all valid ShippingLevel values for easy lookup
var validShippingLevelValues = map[ShippingLevel]struct{}{
Mail: {},
PriorityMail: {},
Ground: {},
Expedited: {},
Express: {},
}
// Valid validates if a value is a valid ShippingLevel
func (v ShippingLevel) Valid() bool {
_, ok := validShippingLevelValues[v]
return ok
}
// ShippingLevelValues returns a list of all (valid) ShippingLevel values
func ShippingLevelValues() []ShippingLevel {
return []ShippingLevel{
Mail,
PriorityMail,
Ground,
Expedited,
Express,
}
}
// UnmarshalText takes a text, verifies that it is a correct ShippingLevel and unmarshals it
func (v *ShippingLevel) UnmarshalText(text []byte) error {
if valid := ShippingLevel(text).Valid(); !valid {
return fmt.Errorf("not valid value for ShippingLevel: %s", text)
}
*v = ShippingLevel(text)
return nil
}
// validTitleValues contains a map of all valid Title values for easy lookup
var validTitleValues = map[Title]struct{}{
Mr: {},
Miss: {},
Mrs: {},
Ms: {},
Dr: {},
}
// Valid validates if a value is a valid Title
func (v Title) Valid() bool {
_, ok := validTitleValues[v]
return ok
}
// TitleValues returns a list of all (valid) Title values
func TitleValues() []Title {
return []Title{
Mr,
Miss,
Mrs,
Ms,
Dr,
}
}
// UnmarshalText takes a text, verifies that it is a correct Title and unmarshals it
func (v *Title) UnmarshalText(text []byte) error {
if valid := Title(text).Valid(); !valid {
return fmt.Errorf("not valid value for Title: %s", text)
}
*v = Title(text)
return nil
}
|