@@ -9,22 +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' ,
14- intMinZero ( body ( 'crId' ) ) ,
15- nonEmptyString ( body ( 'name' ) ) ,
16- intMinZero ( body ( 'carNumber' ) ) ,
17- nonEmptyString ( body ( 'summary' ) ) ,
18- validateInputs ,
19- ProjectsController . createProject
20- ) ;
2112
22- projectRouter . post (
23- '/edit' ,
24- intMinZero ( body ( 'projectId' ) ) ,
13+ const projectValidators = [
2514 intMinZero ( body ( 'crId' ) ) ,
2615 nonEmptyString ( body ( 'name' ) ) ,
27- intMinZero ( body ( 'budget' ) ) ,
2816 nonEmptyString ( body ( 'summary' ) ) ,
2917 body ( 'rules' ) . isArray ( ) ,
3018 nonEmptyString ( body ( 'rules.*' ) ) ,
@@ -41,7 +29,24 @@ projectRouter.post(
4129 nonEmptyString ( body ( 'links.*.url' ) ) ,
4230 nonEmptyString ( body ( 'links.*.linkTypeName' ) ) ,
4331 intMinZero ( body ( 'projectLeadId' ) . optional ( ) ) ,
44- 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+ nonEmptyString ( 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 ,
4550 validateInputs ,
4651 ProjectsController . editProject
4752) ;
0 commit comments