aboutsummaryrefslogtreecommitdiff
path: root/ride/category.go
blob: 6a3431ccc91fa06ba14528ca365a79509fe7e2c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

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"
	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)
}