aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/jobs.ts20
1 files changed, 5 insertions, 15 deletions
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'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
6 6
7const listJobsValidator = [ 7const listJobsValidator = [
8 param('state')
9 .optional()
10 .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
11
8 query('jobType') 12 query('jobType')
9 .optional() 13 .optional()
10 .custom(isValidJobType).withMessage('Should have a valid job state'), 14 .custom(isValidJobType).withMessage('Should have a valid job state'),
@@ -18,22 +22,8 @@ const listJobsValidator = [
18 } 22 }
19] 23]
20 24
21const listJobsStateValidator = [
22 param('state')
23 .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
24
25 (req: express.Request, res: express.Response, next: express.NextFunction) => {
26 logger.debug('Checking listJobsValidator parameters.', { parameters: req.params })
27
28 if (areValidationErrors(req, res)) return
29
30 return next()
31 }
32]
33
34// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
35 26
36export { 27export {
37 listJobsValidator, 28 listJobsValidator
38 listJobsStateValidator
39} 29}