aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/middlewares/validators/user-history.ts
blob: 418313d09812d8a365f757b0b15462c05d54e49c (plain) (tree)
1
2
3
4
5
6

                                  
                                              

                                             
                                                                  



















                                                                                            
import * as express from 'express'
import 'express-validator'
import { body } from 'express-validator/check'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isDateValid } from '../../helpers/custom-validators/misc'

const userHistoryRemoveValidator = [
  body('beforeDate')
    .optional()
    .custom(isDateValid).withMessage('Should have a valid before date'),

  (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 {
  userHistoryRemoveValidator
}