package ride type BikeType string const ( BikeTypeRoad BikeType = "road" BikeTypeMTB BikeType = "mtb" ) type RideType string const ( RideTypeTraining RideType = "training" RideTypeIndoor RideType = "indoor" RideTypeRace RideType = "race" RideTypeTransport RideType = "transport" ) var validBikeTypes = map[BikeType]struct{}{ BikeTypeRoad: {}, BikeTypeMTB: {}, } var validRideTypes = map[RideType]struct{}{ RideTypeTraining: {}, RideTypeIndoor: {}, RideTypeRace: {}, RideTypeTransport: {}, } var AllBikeTypes = []BikeType{BikeTypeRoad, BikeTypeMTB} var AllRideTypes = []RideType{RideTypeTraining, RideTypeIndoor, RideTypeRace, RideTypeTransport} func IsValidBikeType(value string) bool { _, ok := validBikeTypes[BikeType(value)] return ok } func IsValidRideType(value string) bool { _, ok := validRideTypes[RideType(value)] return ok } func IsValidOrEmptyBikeType(value string) bool { if value == "" { return true } return IsValidBikeType(value) } func IsValidOrEmptyRideType(value string) bool { if value == "" { return true } return IsValidRideType(value) }