aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-09 16:39:45 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-10 14:02:41 +0200
commit3b0bd70aa05ab82fa30fe67ed4899d44652c703a (patch)
tree662655e40f0a4263f1d3ab457d9970c344e8bbb0 /server/middlewares/validators
parent7c87746e4b336e547b1917f274c9a0bdc4d1d3df (diff)
downloadPeerTube-3b0bd70aa05ab82fa30fe67ed4899d44652c703a.tar.gz
PeerTube-3b0bd70aa05ab82fa30fe67ed4899d44652c703a.tar.zst
PeerTube-3b0bd70aa05ab82fa30fe67ed4899d44652c703a.zip
Add search target check params
Diffstat (limited to 'server/middlewares/validators')
-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 })