// 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 }