diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-23 21:35:59 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-23 21:35:59 +0200 |
| commit | 08fdd6964fd9ef29356420b035e2d186546f674a (patch) | |
| tree | 812565b5ca57405a5b36b2d7edfab983f6f079d4 /ride/category.go | |
| parent | 2d8503cafb9f63ca4cb63f041281987f9a63f16a (diff) | |
Add hardcore ride categorisation with bike and ride types
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) +} |
