]>
Commit | Line | Data |
---|---|---|
94a5ff8a | 1 | import * as express from 'express' |
1061c73f C |
2 | import { param, query } from 'express-validator' |
3 | import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' | |
94a5ff8a C |
4 | import { logger } from '../../helpers/logger' |
5 | import { areValidationErrors } from './utils' | |
6 | ||
7 | const listJobsValidator = [ | |
1061c73f C |
8 | param('state') |
9 | .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | |
10 | query('jobType') | |
11 | .optional() | |
12 | .custom(isValidJobType).withMessage('Should have a valid job state'), | |
94a5ff8a | 13 | |
1061c73f | 14 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
94a5ff8a C |
15 | logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) |
16 | ||
17 | if (areValidationErrors(req, res)) return | |
18 | ||
19 | return next() | |
20 | } | |
21 | ] | |
22 | ||
23 | // --------------------------------------------------------------------------- | |
24 | ||
25 | export { | |
26 | listJobsValidator | |
27 | } |