@@ -36,30 +36,36 @@ const numbers = (values: string[]) =>
3636 values . map ( v => parseInt ( v ) ) . filter ( Number . isNaN )
3737const firstNumber = ( values : string [ ] ) => numbers ( values ) [ 0 ]
3838
39+ const floats = ( values : string [ ] ) =>
40+ values . map ( v => parseFloat ( v ) ) . filter ( Number . isNaN )
41+ const firstFloat = ( values : string [ ] ) => floats ( values ) [ 0 ]
42+
3943type QueryParamValidators < ReqParams > = {
4044 [ k in keyof Required < ReqParams > ] : ( v : string [ ] ) => ReqParams [ k ]
4145}
4246
4347const 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
6369}
6470
6571const contentSearchValidators : QueryParamValidators < ContentFileSearchRequest > =
@@ -78,7 +84,8 @@ const contentSearchValidators: QueryParamValidators<ContentFileSearchRequest> =
7884 sortby : values =>
7985 withinEnum ( Object . values ( ContentFileSearchRetrieveSortbyEnum ) ) ( values ) [ 0 ] ,
8086 resource_id : numbers ,
81- run_id : numbers
87+ run_id : numbers ,
88+ dev_mode : firstBoolean
8289 }
8390
8491export { resourceSearchValidators , contentSearchValidators }
0 commit comments