diff options
Diffstat (limited to 'server/middlewares/validators/jobs.ts')
-rw-r--r-- | server/middlewares/validators/jobs.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts index 41a8d6899..b57615dbc 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/middlewares/validators/jobs.ts | |||
@@ -1,13 +1,17 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param, query } from 'express-validator' |
3 | import { isValidJobState } from '../../helpers/custom-validators/jobs' | 3 | import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | 6 | ||
7 | const listJobsValidator = [ | 7 | const listJobsValidator = [ |
8 | param('state').custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | 8 | param('state') |
9 | .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | ||
10 | query('jobType') | ||
11 | .optional() | ||
12 | .custom(isValidJobType).withMessage('Should have a valid job state'), | ||
9 | 13 | ||
10 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 14 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
11 | logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) | 15 | logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) |
12 | 16 | ||
13 | if (areValidationErrors(req, res)) return | 17 | if (areValidationErrors(req, res)) return |