-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
35 lines (29 loc) · 993 Bytes
/
types.go
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
package validator
type Comparator string
type ComparatorDescription byte
const (
EQUALS Comparator = "="
NOT_EQUAL Comparator = "!="
LESS_THAN Comparator = "<"
GREATER_THAN Comparator = ">"
LESS_THAN_OR_EQUAL Comparator = "<="
GREATER_THAN_OR_EQUAL Comparator = ">="
)
const (
NUMERICAL ComparatorDescription = 0
TEMPORAL ComparatorDescription = 1
)
var comparatorDescriptors = map[Comparator][]string{
EQUALS: {"equal", "the same as"},
NOT_EQUAL: {"not equal", "not the same as"},
LESS_THAN: {"less than", "before"},
GREATER_THAN: {"greater than", "after"},
LESS_THAN_OR_EQUAL: {"less than or equal", "at most"},
GREATER_THAN_OR_EQUAL: {"greater than or equal", "at least"},
}
func (c Comparator) NumericDescription() string {
return comparatorDescriptors[c][NUMERICAL]
}
func (c Comparator) TemporalDescription() string {
return comparatorDescriptors[c][TEMPORAL]
}