diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/jobs.ts | 20 |
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' | |||
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | 6 | ||
7 | const listJobsValidator = [ | 7 | const 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 | ||
21 | const 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 | ||
36 | export { | 27 | export { |
37 | listJobsValidator, | 28 | listJobsValidator |
38 | listJobsStateValidator | ||
39 | } | 29 | } |