From 402145b8630d1908c35f8c22846ddc4475f25d3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Dec 2020 12:00:35 +0100 Subject: Refactor jobs state --- server/middlewares/validators/jobs.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts index 0fc183c1a..99ef25e0a 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/middlewares/validators/jobs.ts @@ -5,6 +5,10 @@ import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' const listJobsValidator = [ + param('state') + .optional() + .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), + query('jobType') .optional() .custom(isValidJobType).withMessage('Should have a valid job state'), @@ -18,22 +22,8 @@ const listJobsValidator = [ } ] -const listJobsStateValidator = [ - param('state') - .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), - - (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) - - if (areValidationErrors(req, res)) return - - return next() - } -] - // --------------------------------------------------------------------------- export { - listJobsValidator, - listJobsStateValidator + listJobsValidator } -- cgit v1.2.3