diff options
Diffstat (limited to 'ride/category.go')
| -rw-r--r-- | ride/category.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ride/category.go b/ride/category.go new file mode 100644 index 0000000..0eafcc0 --- /dev/null +++ b/ride/category.go @@ -0,0 +1,56 @@ +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) +} |
