aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/user-history.ts19
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator' 2import { body, query } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { isDateValid } from '../../helpers/custom-validators/misc' 5import { exists, isDateValid } from '../../helpers/custom-validators/misc'
6
7const 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
7const userHistoryRemoveValidator = [ 21const userHistoryRemoveValidator = [
8 body('beforeDate') 22 body('beforeDate')
@@ -21,5 +35,6 @@ const userHistoryRemoveValidator = [
21// --------------------------------------------------------------------------- 35// ---------------------------------------------------------------------------
22 36
23export { 37export {
38 userHistoryListValidator,
24 userHistoryRemoveValidator 39 userHistoryRemoveValidator
25} 40}