@@ -2,7 +2,7 @@ const joi = require('joi')
2
2
const { DINERO , NEELAM } = require ( '../../constants/wallets' )
3
3
4
4
const createTask = async ( req , res , next ) => {
5
- const schema = joi . object ( ) . keys ( {
5
+ const schema = joi . object ( ) . strict ( ) . keys ( {
6
6
title : joi . string ( ) . required ( ) ,
7
7
purpose : joi . string ( ) . optional ( ) ,
8
8
featureUrl : joi . string ( ) . optional ( ) ,
@@ -36,7 +36,7 @@ const createTask = async (req, res, next) => {
36
36
}
37
37
38
38
const updateTask = async ( req , res , next ) => {
39
- const schema = joi . object ( ) . keys ( {
39
+ const schema = joi . object ( ) . strict ( ) . keys ( {
40
40
title : joi . string ( ) . optional ( ) ,
41
41
purpose : joi . string ( ) . optional ( ) ,
42
42
featureUrl : joi . string ( ) . optional ( ) ,
@@ -68,7 +68,22 @@ const updateTask = async (req, res, next) => {
68
68
}
69
69
}
70
70
71
+ const updateSelfTask = async ( req , res , next ) => {
72
+ const schema = joi . object ( ) . strict ( ) . keys ( {
73
+ status : joi . string ( ) . optional ( ) ,
74
+ percentCompleted : joi . number ( ) . optional ( )
75
+ } )
76
+ try {
77
+ await schema . validateAsync ( req . body )
78
+ next ( )
79
+ } catch ( error ) {
80
+ logger . error ( `Error validating updateSelfTask payload : ${ error } ` )
81
+ res . boom . badRequest ( error . details [ 0 ] . message )
82
+ }
83
+ }
84
+
71
85
module . exports = {
72
86
createTask,
73
- updateTask
87
+ updateTask,
88
+ updateSelfTask
74
89
}
0 commit comments