package ride type BikeType string const ( BikeTypeRoad BikeType = "road" BikeTypeMTB BikeType = "mtb" ) func BikeTypeForExternalSportType(value string) (BikeType, bool) { switch value { case "Ride": return BikeTypeRoad, true case "MountainBikeRide": return BikeTypeMTB, true default: return "", false } } type RideType string const ( RideTypeTraining RideType = "training" RideTypeIndoor RideType = "indoor" RideTypeRace RideType = "race" RideTypeTransport RideType = "transport" RideTypeTouring RideType = "touring" ) var validBikeTypes = map[BikeType]struct{}{ BikeTypeRoad: {}, BikeTypeMTB: {}, } var validRideTypes = map[RideType]struct{}{ RideTypeTraining: {}, RideTypeIndoor: {}, RideTypeRace: {}, RideTypeTransport: {}, RideTypeTouring: {}, } var AllRideTypes = []RideType{RideTypeTraining, RideTypeIndoor, RideTypeRace, RideTypeTransport, RideTypeTouring} 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) }