]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/middlewares/validators/user-history.ts
Add ability to filter my videos by live
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / user-history.ts
... / ...
CommitLineData
1import * as express from 'express'
2import { body, query } from 'express-validator'
3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils'
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]
20
21const userHistoryRemoveValidator = [
22 body('beforeDate')
23 .optional()
24 .custom(isDateValid).withMessage('Should have a valid before date'),
25
26 (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body })
28
29 if (areValidationErrors(req, res)) return
30
31 return next()
32 }
33]
34
35// ---------------------------------------------------------------------------
36
37export {
38 userHistoryListValidator,
39 userHistoryRemoveValidator
40}