File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const addProjectPhaseValidations = {
14
14
param : Joi . object ( ) . keys ( {
15
15
name : Joi . string ( ) . required ( ) ,
16
16
status : Joi . string ( ) . required ( ) ,
17
- startDate : Joi . date ( ) . max ( Joi . ref ( 'endDate' ) ) . optional ( ) ,
17
+ startDate : Joi . date ( ) . optional ( ) ,
18
18
endDate : Joi . date ( ) . optional ( ) ,
19
19
duration : Joi . number ( ) . min ( 0 ) . optional ( ) ,
20
20
budget : Joi . number ( ) . min ( 0 ) . optional ( ) ,
@@ -52,6 +52,11 @@ module.exports = [
52
52
err . status = 404 ;
53
53
throw err ;
54
54
}
55
+ if ( data . startDate !== null && data . endDate !== null && data . startDate > data . endDate ) {
56
+ const err = new Error ( 'startDate must not be after endDate.' ) ;
57
+ err . status = 400 ;
58
+ throw err ;
59
+ }
55
60
return models . ProjectPhase
56
61
. create ( data )
57
62
. then ( ( _newProjectPhase ) => {
You can’t perform that action at this time.
0 commit comments