diff options
Diffstat (limited to 'server/middlewares/validators/search.ts')
-rw-r--r-- | server/middlewares/validators/search.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts index e516c4c41..8baf643a5 100644 --- a/server/middlewares/validators/search.ts +++ b/server/middlewares/validators/search.ts | |||
@@ -5,7 +5,7 @@ import { query } from 'express-validator/check' | |||
5 | import { isNumberArray, isStringArray, isNSFWQueryValid } from '../../helpers/custom-validators/search' | 5 | import { isNumberArray, isStringArray, isNSFWQueryValid } from '../../helpers/custom-validators/search' |
6 | import { isBooleanValid, isDateValid, toArray } from '../../helpers/custom-validators/misc' | 6 | import { isBooleanValid, isDateValid, toArray } from '../../helpers/custom-validators/misc' |
7 | 7 | ||
8 | const searchValidator = [ | 8 | const videosSearchValidator = [ |
9 | query('search').optional().not().isEmpty().withMessage('Should have a valid search'), | 9 | query('search').optional().not().isEmpty().withMessage('Should have a valid search'), |
10 | 10 | ||
11 | query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'), | 11 | query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'), |
@@ -15,7 +15,19 @@ const searchValidator = [ | |||
15 | query('durationMax').optional().isInt().withMessage('Should have a valid max duration'), | 15 | query('durationMax').optional().isInt().withMessage('Should have a valid max duration'), |
16 | 16 | ||
17 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 17 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
18 | logger.debug('Checking search query', { parameters: req.query }) | 18 | logger.debug('Checking videos search query', { parameters: req.query }) |
19 | |||
20 | if (areValidationErrors(req, res)) return | ||
21 | |||
22 | return next() | ||
23 | } | ||
24 | ] | ||
25 | |||
26 | const videoChannelsSearchValidator = [ | ||
27 | query('search').not().isEmpty().withMessage('Should have a valid search'), | ||
28 | |||
29 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
30 | logger.debug('Checking video channels search query', { parameters: req.query }) | ||
19 | 31 | ||
20 | if (areValidationErrors(req, res)) return | 32 | if (areValidationErrors(req, res)) return |
21 | 33 | ||
@@ -61,5 +73,6 @@ const commonVideosFiltersValidator = [ | |||
61 | 73 | ||
62 | export { | 74 | export { |
63 | commonVideosFiltersValidator, | 75 | commonVideosFiltersValidator, |
64 | searchValidator | 76 | videoChannelsSearchValidator, |
77 | videosSearchValidator | ||
65 | } | 78 | } |