@@ -10,11 +10,7 @@ projectRouter.get('/', ProjectsController.getAllProjects);
1010projectRouter . get ( '/link-types' , ProjectsController . getAllLinkTypes ) ;
1111projectRouter . get ( '/:wbsNum' , ProjectsController . getSingleProject ) ;
1212
13- projectRouter . post (
14- '/create' ,
15- intMinZero ( body ( 'carNumber' ) ) ,
16- body ( 'teamIds' ) . isArray ( ) ,
17- intMinZero ( body ( 'teamIds.*' ) ) ,
13+ const projectValidators = [
1814 intMinZero ( body ( 'crId' ) ) ,
1915 nonEmptyString ( body ( 'name' ) ) ,
2016 intMinZero ( body ( 'budget' ) ) ,
@@ -34,33 +30,22 @@ projectRouter.post(
3430 nonEmptyString ( body ( 'links.*.url' ) ) ,
3531 nonEmptyString ( body ( 'links.*.linkTypeName' ) ) ,
3632 intMinZero ( body ( 'projectLeadId' ) . optional ( ) ) ,
37- intMinZero ( body ( 'projectManagerId' ) . optional ( ) ) ,
33+ intMinZero ( body ( 'projectManagerId' ) . optional ( ) )
34+ ] ;
35+
36+ projectRouter . post (
37+ '/create' ,
38+ intMinZero ( body ( 'carNumber' ) ) ,
39+ body ( 'teamIds' ) . isArray ( ) ,
40+ intMinZero ( body ( 'teamIds.*' ) ) ,
41+ ...projectValidators ,
3842 validateInputs ,
3943 ProjectsController . createProject
4044) ;
4145projectRouter . post (
4246 '/edit' ,
4347 intMinZero ( body ( 'projectId' ) ) ,
44- intMinZero ( body ( 'crId' ) ) ,
45- nonEmptyString ( body ( 'name' ) ) ,
46- intMinZero ( body ( 'budget' ) ) ,
47- nonEmptyString ( body ( 'summary' ) ) ,
48- body ( 'rules' ) . isArray ( ) ,
49- nonEmptyString ( body ( 'rules.*' ) ) ,
50- body ( 'goals' ) . isArray ( ) ,
51- body ( 'goals.*.id' ) . isInt ( { min : - 1 } ) . not ( ) . isString ( ) ,
52- nonEmptyString ( body ( 'goals.*.detail' ) ) ,
53- body ( 'features' ) . isArray ( ) ,
54- body ( 'features.*.id' ) . isInt ( { min : - 1 } ) . not ( ) . isString ( ) ,
55- nonEmptyString ( body ( 'features.*.detail' ) ) ,
56- body ( 'otherConstraints' ) . isArray ( ) ,
57- body ( 'otherConstraints.*.id' ) . isInt ( { min : - 1 } ) . not ( ) . isString ( ) ,
58- nonEmptyString ( body ( 'otherConstraints.*.detail' ) ) ,
59- body ( 'links' ) . isArray ( ) ,
60- nonEmptyString ( body ( 'links.*.url' ) ) ,
61- nonEmptyString ( body ( 'links.*.linkTypeName' ) ) ,
62- intMinZero ( body ( 'projectLeadId' ) . optional ( ) ) ,
63- intMinZero ( body ( 'projectManagerId' ) . optional ( ) ) ,
48+ ...projectValidators ,
6449 validateInputs ,
6550 ProjectsController . editProject
6651) ;
0 commit comments