From 1061c73fde3005100ead8764eacb444f240440d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 4 Dec 2019 14:49:59 +0100 Subject: Add ability to filter per job type --- server/middlewares/validators/jobs.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'server/middlewares') 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 @@ import * as express from 'express' -import { param } from 'express-validator' -import { isValidJobState } from '../../helpers/custom-validators/jobs' +import { param, query } from 'express-validator' +import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' const listJobsValidator = [ - param('state').custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), + 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'), - async (req: express.Request, res: express.Response, next: express.NextFunction) => { + (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) if (areValidationErrors(req, res)) return -- cgit v1.2.3