diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-17 14:27:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-17 14:27:04 +0200 |
commit | 396f6f0140b0f76162e2378fd5a61e2f888673ed (patch) | |
tree | a5bd668bfc7dca7f311b9fc42ebb8bd01f462648 /server/middlewares/validators/search.ts | |
parent | 97eba003a9d0adcb0cab9190f566327b1417c7d3 (diff) | |
download | PeerTube-396f6f0140b0f76162e2378fd5a61e2f888673ed.tar.gz PeerTube-396f6f0140b0f76162e2378fd5a61e2f888673ed.tar.zst PeerTube-396f6f0140b0f76162e2378fd5a61e2f888673ed.zip |
Cleanup useless express validator messages
Diffstat (limited to 'server/middlewares/validators/search.ts')
-rw-r--r-- | server/middlewares/validators/search.ts | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts index e6ec8642a..827132468 100644 --- a/server/middlewares/validators/search.ts +++ b/server/middlewares/validators/search.ts | |||
@@ -7,11 +7,13 @@ import { logger } from '../../helpers/logger' | |||
7 | import { areValidationErrors } from './shared' | 7 | import { areValidationErrors } from './shared' |
8 | 8 | ||
9 | const videosSearchValidator = [ | 9 | const videosSearchValidator = [ |
10 | query('search').optional().not().isEmpty().withMessage('Should have a valid search'), | 10 | query('search') |
11 | .optional() | ||
12 | .not().isEmpty(), | ||
11 | 13 | ||
12 | query('host') | 14 | query('host') |
13 | .optional() | 15 | .optional() |
14 | .custom(isHostValid).withMessage('Should have a valid host'), | 16 | .custom(isHostValid), |
15 | 17 | ||
16 | query('startDate') | 18 | query('startDate') |
17 | .optional() | 19 | .optional() |
@@ -29,18 +31,20 @@ const videosSearchValidator = [ | |||
29 | 31 | ||
30 | query('durationMin') | 32 | query('durationMin') |
31 | .optional() | 33 | .optional() |
32 | .isInt().withMessage('Should have a valid min duration'), | 34 | .isInt(), |
33 | query('durationMax') | 35 | query('durationMax') |
34 | .optional() | 36 | .optional() |
35 | .isInt().withMessage('Should have a valid max duration'), | 37 | .isInt(), |
36 | 38 | ||
37 | query('uuids') | 39 | query('uuids') |
38 | .optional() | 40 | .optional() |
39 | .toArray() | 41 | .toArray() |
40 | .customSanitizer(toCompleteUUIDs) | 42 | .customSanitizer(toCompleteUUIDs) |
41 | .custom(areUUIDsValid).withMessage('Should have valid uuids'), | 43 | .custom(areUUIDsValid).withMessage('Should have valid array of uuid'), |
42 | 44 | ||
43 | query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'), | 45 | query('searchTarget') |
46 | .optional() | ||
47 | .custom(isSearchTargetValid), | ||
44 | 48 | ||
45 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 49 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
46 | logger.debug('Checking videos search query', { parameters: req.query }) | 50 | logger.debug('Checking videos search query', { parameters: req.query }) |
@@ -54,20 +58,20 @@ const videosSearchValidator = [ | |||
54 | const videoChannelsListSearchValidator = [ | 58 | const videoChannelsListSearchValidator = [ |
55 | query('search') | 59 | query('search') |
56 | .optional() | 60 | .optional() |
57 | .not().isEmpty().withMessage('Should have a valid search'), | 61 | .not().isEmpty(), |
58 | 62 | ||
59 | query('host') | 63 | query('host') |
60 | .optional() | 64 | .optional() |
61 | .custom(isHostValid).withMessage('Should have a valid host'), | 65 | .custom(isHostValid), |
62 | 66 | ||
63 | query('searchTarget') | 67 | query('searchTarget') |
64 | .optional() | 68 | .optional() |
65 | .custom(isSearchTargetValid).withMessage('Should have a valid search target'), | 69 | .custom(isSearchTargetValid), |
66 | 70 | ||
67 | query('handles') | 71 | query('handles') |
68 | .optional() | 72 | .optional() |
69 | .toArray() | 73 | .toArray() |
70 | .custom(isNotEmptyStringArray).withMessage('Should have valid handles'), | 74 | .custom(isNotEmptyStringArray).withMessage('Should have valid array of handles'), |
71 | 75 | ||
72 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 76 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
73 | logger.debug('Checking video channels search query', { parameters: req.query }) | 77 | logger.debug('Checking video channels search query', { parameters: req.query }) |
@@ -81,21 +85,21 @@ const videoChannelsListSearchValidator = [ | |||
81 | const videoPlaylistsListSearchValidator = [ | 85 | const videoPlaylistsListSearchValidator = [ |
82 | query('search') | 86 | query('search') |
83 | .optional() | 87 | .optional() |
84 | .not().isEmpty().withMessage('Should have a valid search'), | 88 | .not().isEmpty(), |
85 | 89 | ||
86 | query('host') | 90 | query('host') |
87 | .optional() | 91 | .optional() |
88 | .custom(isHostValid).withMessage('Should have a valid host'), | 92 | .custom(isHostValid), |
89 | 93 | ||
90 | query('searchTarget') | 94 | query('searchTarget') |
91 | .optional() | 95 | .optional() |
92 | .custom(isSearchTargetValid).withMessage('Should have a valid search target'), | 96 | .custom(isSearchTargetValid), |
93 | 97 | ||
94 | query('uuids') | 98 | query('uuids') |
95 | .optional() | 99 | .optional() |
96 | .toArray() | 100 | .toArray() |
97 | .customSanitizer(toCompleteUUIDs) | 101 | .customSanitizer(toCompleteUUIDs) |
98 | .custom(areUUIDsValid).withMessage('Should have valid uuids'), | 102 | .custom(areUUIDsValid).withMessage('Should have valid array of uuid'), |
99 | 103 | ||
100 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 104 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
101 | logger.debug('Checking video playlists search query', { parameters: req.query }) | 105 | logger.debug('Checking video playlists search query', { parameters: req.query }) |