2018-12-17 09:52:38 -05:00
|
|
|
import * as express from 'express'
|
2021-01-13 03:16:15 -05:00
|
|
|
import { body, query } from 'express-validator'
|
|
|
|
import { exists, isDateValid } from '../../helpers/custom-validators/misc'
|
2021-06-03 11:33:44 -04:00
|
|
|
import { logger } from '../../helpers/logger'
|
|
|
|
import { areValidationErrors } from './shared'
|
2021-01-13 03:16:15 -05:00
|
|
|
|
|
|
|
const userHistoryListValidator = [
|
|
|
|
query('search')
|
|
|
|
.optional()
|
|
|
|
.custom(exists).withMessage('Should have a valid search'),
|
|
|
|
|
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
|
|
logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })
|
|
|
|
|
|
|
|
if (areValidationErrors(req, res)) return
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
]
|
2018-12-17 09:52:38 -05:00
|
|
|
|
|
|
|
const userHistoryRemoveValidator = [
|
|
|
|
body('beforeDate')
|
|
|
|
.optional()
|
2021-05-31 13:47:14 -04:00
|
|
|
.custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'),
|
2018-12-17 09:52:38 -05:00
|
|
|
|
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
|
|
logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body })
|
|
|
|
|
|
|
|
if (areValidationErrors(req, res)) return
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2021-01-13 03:16:15 -05:00
|
|
|
userHistoryListValidator,
|
2018-12-17 09:52:38 -05:00
|
|
|
userHistoryRemoveValidator
|
|
|
|
}
|