aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/search.ts')
-rw-r--r--server/middlewares/validators/search.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts
index 5a3c83f2c..b4faa8894 100644
--- a/server/middlewares/validators/search.ts
+++ b/server/middlewares/validators/search.ts
@@ -3,6 +3,7 @@ import { areValidationErrors } from './utils'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { query } from 'express-validator' 4import { query } from 'express-validator'
5import { isDateValid } from '../../helpers/custom-validators/misc' 5import { isDateValid } from '../../helpers/custom-validators/misc'
6import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
6 7
7const videosSearchValidator = [ 8const videosSearchValidator = [
8 query('search').optional().not().isEmpty().withMessage('Should have a valid search'), 9 query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
@@ -16,6 +17,8 @@ const videosSearchValidator = [
16 query('durationMin').optional().isInt().withMessage('Should have a valid min duration'), 17 query('durationMin').optional().isInt().withMessage('Should have a valid min duration'),
17 query('durationMax').optional().isInt().withMessage('Should have a valid max duration'), 18 query('durationMax').optional().isInt().withMessage('Should have a valid max duration'),
18 19
20 query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'),
21
19 (req: express.Request, res: express.Response, next: express.NextFunction) => { 22 (req: express.Request, res: express.Response, next: express.NextFunction) => {
20 logger.debug('Checking videos search query', { parameters: req.query }) 23 logger.debug('Checking videos search query', { parameters: req.query })
21 24
@@ -27,6 +30,7 @@ const videosSearchValidator = [
27 30
28const videoChannelsSearchValidator = [ 31const videoChannelsSearchValidator = [
29 query('search').not().isEmpty().withMessage('Should have a valid search'), 32 query('search').not().isEmpty().withMessage('Should have a valid search'),
33 query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'),
30 34
31 (req: express.Request, res: express.Response, next: express.NextFunction) => { 35 (req: express.Request, res: express.Response, next: express.NextFunction) => {
32 logger.debug('Checking video channels search query', { parameters: req.query }) 36 logger.debug('Checking video channels search query', { parameters: req.query })