@@ -9,21 +9,10 @@ const projectRouter = express.Router();
99projectRouter . get ( '/' , ProjectsController . getAllProjects ) ;
1010projectRouter . get ( '/link-types' , ProjectsController . getAllLinkTypes ) ;
1111projectRouter . get ( '/:wbsNum' , ProjectsController . getSingleProject ) ;
12- projectRouter . post (
13- '/create' ,
12+
13+ const projectValidators = [
1414 intMinZero ( body ( 'crId' ) ) ,
1515 nonEmptyString ( body ( 'name' ) ) ,
16- intMinZero ( body ( 'carNumber' ) ) ,
17- nonEmptyString ( body ( 'summary' ) ) ,
18- validateInputs ,
19- ProjectsController . createProject
20- ) ;
21- projectRouter . post (
22- '/edit' ,
23- intMinZero ( body ( 'projectId' ) ) ,
24- intMinZero ( body ( 'crId' ) ) ,
25- nonEmptyString ( body ( 'name' ) ) ,
26- intMinZero ( body ( 'budget' ) ) ,
2716 nonEmptyString ( body ( 'summary' ) ) ,
2817 body ( 'rules' ) . isArray ( ) ,
2918 nonEmptyString ( body ( 'rules.*' ) ) ,
@@ -40,7 +29,24 @@ projectRouter.post(
4029 nonEmptyString ( body ( 'links.*.url' ) ) ,
4130 nonEmptyString ( body ( 'links.*.linkTypeName' ) ) ,
4231 intMinZero ( body ( 'projectLeadId' ) . optional ( ) ) ,
43- intMinZero ( body ( 'projectManagerId' ) . optional ( ) ) ,
32+ intMinZero ( body ( 'projectManagerId' ) . optional ( ) )
33+ ] ;
34+
35+ projectRouter . post (
36+ '/create' ,
37+ intMinZero ( body ( 'carNumber' ) ) ,
38+ body ( 'teamIds' ) . isArray ( ) ,
39+ intMinZero ( body ( 'teamIds.*' ) ) ,
40+ body ( 'budget' ) . optional ( ) . isInt ( { min : 0 } ) . default ( 0 ) ,
41+ ...projectValidators ,
42+ validateInputs ,
43+ ProjectsController . createProject
44+ ) ;
45+ projectRouter . post (
46+ '/edit' ,
47+ intMinZero ( body ( 'projectId' ) ) ,
48+ intMinZero ( body ( 'budget' ) ) ,
49+ ...projectValidators ,
4450 validateInputs ,
4551 ProjectsController . editProject
4652) ;
0 commit comments