diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/user-history.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts index 2f1d3cc41..058bf7758 100644 --- a/server/middlewares/validators/user-history.ts +++ b/server/middlewares/validators/user-history.ts | |||
@@ -1,8 +1,22 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body, query } from 'express-validator' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { areValidationErrors } from './utils' | 4 | import { areValidationErrors } from './utils' |
5 | import { isDateValid } from '../../helpers/custom-validators/misc' | 5 | import { exists, isDateValid } from '../../helpers/custom-validators/misc' |
6 | |||
7 | const userHistoryListValidator = [ | ||
8 | query('search') | ||
9 | .optional() | ||
10 | .custom(exists).withMessage('Should have a valid search'), | ||
11 | |||
12 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
13 | logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query }) | ||
14 | |||
15 | if (areValidationErrors(req, res)) return | ||
16 | |||
17 | return next() | ||
18 | } | ||
19 | ] | ||
6 | 20 | ||
7 | const userHistoryRemoveValidator = [ | 21 | const userHistoryRemoveValidator = [ |
8 | body('beforeDate') | 22 | body('beforeDate') |
@@ -21,5 +35,6 @@ const userHistoryRemoveValidator = [ | |||
21 | // --------------------------------------------------------------------------- | 35 | // --------------------------------------------------------------------------- |
22 | 36 | ||
23 | export { | 37 | export { |
38 | userHistoryListValidator, | ||
24 | userHistoryRemoveValidator | 39 | userHistoryRemoveValidator |
25 | } | 40 | } |