From 040d6896a3cd5622e78cccdedd8cce2afcf49a31 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 13 Dec 2020 19:27:25 +0100 Subject: add display of logs matching any state --- server/middlewares/validators/jobs.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'server/middlewares/validators/jobs.ts') diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts index b57615dbc..0fc183c1a 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/middlewares/validators/jobs.ts @@ -5,8 +5,6 @@ import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' const listJobsValidator = [ - param('state') - .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), query('jobType') .optional() .custom(isValidJobType).withMessage('Should have a valid job state'), @@ -20,8 +18,22 @@ 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 + listJobsValidator, + listJobsStateValidator } -- cgit v1.2.3