diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-05-11 16:20:15 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-05-11 16:20:15 -0400 |
| commit | 6f2c582f691c6984d5296b714ae41477a102a77b (patch) | |
| tree | 6a6c80d4281acad5522f0772ee2629587a32ab8f /ship_gen.go | |
| parent | af2de318402df1fd8d33192d71613c21c4ee96bf (diff) | |
| download | lulu-6f2c582f691c6984d5296b714ae41477a102a77b.zip | |
include generated code
Diffstat (limited to 'ship_gen.go')
| -rw-r--r-- | ship_gen.go | 76 |
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 +} |