@@ -36,30 +36,36 @@ const numbers = (values: string[]) =>
36
36
values . map ( v => parseInt ( v ) ) . filter ( Number . isNaN )
37
37
const firstNumber = ( values : string [ ] ) => numbers ( values ) [ 0 ]
38
38
39
+ const floats = ( values : string [ ] ) =>
40
+ values . map ( v => parseFloat ( v ) ) . filter ( Number . isNaN )
41
+ const firstFloat = ( values : string [ ] ) => floats ( values ) [ 0 ]
42
+
39
43
type QueryParamValidators < ReqParams > = {
40
44
[ k in keyof Required < ReqParams > ] : ( v : string [ ] ) => ReqParams [ k ]
41
45
}
42
46
43
47
const resourceSearchValidators : QueryParamValidators < ResourceSearchRequest > = {
44
- resource_type : withinEnum ( Object . values ( ResourceTypeEnum ) ) ,
45
- department : withinEnum ( Object . values ( DepartmentEnum ) ) ,
46
- level : withinEnum ( Object . values ( LevelEnum ) ) ,
47
- platform : withinEnum ( Object . values ( PlatformEnum ) ) ,
48
- offered_by : withinEnum ( Object . values ( OfferedByEnum ) ) ,
49
- sortby : values => withinEnum ( Object . values ( SortByEnum ) ) ( values ) [ 0 ] ,
50
- q : first ,
51
- topic : identity ,
52
- certification : firstBoolean ,
53
- professional : firstBoolean ,
54
- aggregations : withinEnum ( Object . values ( AggregationsEnum ) ) ,
55
- course_feature : identity ,
56
- limit : firstNumber ,
57
- offset : firstNumber ,
58
- id : numbers ,
59
- free : firstBoolean ,
60
- learning_format : withinEnum ( Object . values ( LearningFormatEnum ) ) ,
61
- certification_type : withinEnum ( Object . values ( CertificationTypeEnum ) ) ,
62
- resource_category : withinEnum ( Object . values ( ResourceCategoryEnum ) )
48
+ resource_type : withinEnum ( Object . values ( ResourceTypeEnum ) ) ,
49
+ department : withinEnum ( Object . values ( DepartmentEnum ) ) ,
50
+ level : withinEnum ( Object . values ( LevelEnum ) ) ,
51
+ platform : withinEnum ( Object . values ( PlatformEnum ) ) ,
52
+ offered_by : withinEnum ( Object . values ( OfferedByEnum ) ) ,
53
+ sortby : values => withinEnum ( Object . values ( SortByEnum ) ) ( values ) [ 0 ] ,
54
+ q : first ,
55
+ topic : identity ,
56
+ certification : firstBoolean ,
57
+ professional : firstBoolean ,
58
+ aggregations : withinEnum ( Object . values ( AggregationsEnum ) ) ,
59
+ course_feature : identity ,
60
+ limit : firstNumber ,
61
+ offset : firstNumber ,
62
+ id : numbers ,
63
+ free : firstBoolean ,
64
+ learning_format : withinEnum ( Object . values ( LearningFormatEnum ) ) ,
65
+ certification_type : withinEnum ( Object . values ( CertificationTypeEnum ) ) ,
66
+ resource_category : withinEnum ( Object . values ( ResourceCategoryEnum ) ) ,
67
+ yearly_decay_percent : firstFloat ,
68
+ dev_mode : firstBoolean
63
69
}
64
70
65
71
const contentSearchValidators : QueryParamValidators < ContentFileSearchRequest > =
@@ -78,7 +84,8 @@ const contentSearchValidators: QueryParamValidators<ContentFileSearchRequest> =
78
84
sortby : values =>
79
85
withinEnum ( Object . values ( ContentFileSearchRetrieveSortbyEnum ) ) ( values ) [ 0 ] ,
80
86
resource_id : numbers ,
81
- run_id : numbers
87
+ run_id : numbers ,
88
+ dev_mode : firstBoolean
82
89
}
83
90
84
91
export { resourceSearchValidators , contentSearchValidators }
0 commit comments