@@ -50,9 +50,13 @@ const validateCreateProgressRecords = async (req, res, next) => {
50
50
const validateGetProgressRecordsQuery = async ( req , res , next ) => {
51
51
const schema = joi
52
52
. object ( {
53
- type : joi . string ( ) . valid ( "user" , "task" ) . optional ( ) . messages ( {
54
- "any.only" : "Type field is restricted to either 'user' or 'task'." ,
55
- } ) ,
53
+ type : joi
54
+ . string ( )
55
+ . valid ( ...VALID_PROGRESS_TYPES )
56
+ . optional ( )
57
+ . messages ( {
58
+ "any.only" : "Type field is restricted to either 'user' or 'task'." ,
59
+ } ) ,
56
60
userId : joi . string ( ) . optional ( ) . allow ( "" ) . messages ( {
57
61
"string.base" : "userId must be a string" ,
58
62
} ) ,
@@ -101,9 +105,13 @@ const validateGetRangeProgressRecordsParams = async (req, res, next) => {
101
105
102
106
const validateGetDayProgressParams = async ( req , res , next ) => {
103
107
const schema = joi . object ( {
104
- type : joi . string ( ) . valid ( "user" , "task" ) . required ( ) . messages ( {
105
- "any.only" : "Type field is restricted to either 'user' or 'task'." ,
106
- } ) ,
108
+ type : joi
109
+ . string ( )
110
+ . valid ( ...VALID_PROGRESS_TYPES )
111
+ . required ( )
112
+ . messages ( {
113
+ "any.only" : "Type field is restricted to either 'user' or 'task'." ,
114
+ } ) ,
107
115
typeId : joi . string ( ) . required ( ) ,
108
116
date : joi . date ( ) . iso ( ) . required ( ) ,
109
117
} ) ;
0 commit comments