aboutsummaryrefslogtreecommitdiffstats
path: root/ship_gen.go
diff options
context:
space:
mode:
Diffstat (limited to 'ship_gen.go')
-rw-r--r--ship_gen.go76
1 files changed, 76 insertions, 0 deletions
diff --git a/ship_gen.go b/ship_gen.go
new file mode 100644
index 0000000..b45a02e
--- /dev/null
+++ b/ship_gen.go
@@ -0,0 +1,76 @@
+// 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
+}