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/videos/video-playlists.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/videos/video-playlists.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index d514ae0ad..42e6646f9 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts | |||
@@ -45,7 +45,7 @@ import { | |||
45 | 45 | ||
46 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ | 46 | const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([ |
47 | body('displayName') | 47 | body('displayName') |
48 | .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), | 48 | .custom(isVideoPlaylistNameValid), |
49 | 49 | ||
50 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 50 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
51 | logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body }) | 51 | logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body }) |
@@ -73,7 +73,7 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([ | |||
73 | 73 | ||
74 | body('displayName') | 74 | body('displayName') |
75 | .optional() | 75 | .optional() |
76 | .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'), | 76 | .custom(isVideoPlaylistNameValid), |
77 | 77 | ||
78 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 78 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
79 | logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body }) | 79 | logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body }) |
@@ -184,7 +184,9 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => { | |||
184 | } | 184 | } |
185 | 185 | ||
186 | const videoPlaylistsSearchValidator = [ | 186 | const videoPlaylistsSearchValidator = [ |
187 | query('search').optional().not().isEmpty().withMessage('Should have a valid search'), | 187 | query('search') |
188 | .optional() | ||
189 | .not().isEmpty(), | ||
188 | 190 | ||
189 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 191 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
190 | logger.debug('Checking videoPlaylists search query', { parameters: req.query }) | 192 | logger.debug('Checking videoPlaylists search query', { parameters: req.query }) |
@@ -200,13 +202,13 @@ const videoPlaylistsAddVideoValidator = [ | |||
200 | 202 | ||
201 | body('videoId') | 203 | body('videoId') |
202 | .customSanitizer(toCompleteUUID) | 204 | .customSanitizer(toCompleteUUID) |
203 | .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'), | 205 | .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'), |
204 | body('startTimestamp') | 206 | body('startTimestamp') |
205 | .optional() | 207 | .optional() |
206 | .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'), | 208 | .custom(isVideoPlaylistTimestampValid), |
207 | body('stopTimestamp') | 209 | body('stopTimestamp') |
208 | .optional() | 210 | .optional() |
209 | .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'), | 211 | .custom(isVideoPlaylistTimestampValid), |
210 | 212 | ||
211 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 213 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
212 | logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params }) | 214 | logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params }) |
@@ -230,13 +232,13 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [ | |||
230 | isValidPlaylistIdParam('playlistId'), | 232 | isValidPlaylistIdParam('playlistId'), |
231 | param('playlistElementId') | 233 | param('playlistElementId') |
232 | .customSanitizer(toCompleteUUID) | 234 | .customSanitizer(toCompleteUUID) |
233 | .custom(isIdValid).withMessage('Should have an element id/uuid'), | 235 | .custom(isIdValid).withMessage('Should have an element id/uuid/short uuid'), |
234 | body('startTimestamp') | 236 | body('startTimestamp') |
235 | .optional() | 237 | .optional() |
236 | .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'), | 238 | .custom(isVideoPlaylistTimestampValid), |
237 | body('stopTimestamp') | 239 | body('stopTimestamp') |
238 | .optional() | 240 | .optional() |
239 | .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'), | 241 | .custom(isVideoPlaylistTimestampValid), |
240 | 242 | ||
241 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 243 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
242 | logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params }) | 244 | logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params }) |
@@ -266,7 +268,7 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [ | |||
266 | const videoPlaylistElementAPGetValidator = [ | 268 | const videoPlaylistElementAPGetValidator = [ |
267 | isValidPlaylistIdParam('playlistId'), | 269 | isValidPlaylistIdParam('playlistId'), |
268 | param('playlistElementId') | 270 | param('playlistElementId') |
269 | .custom(isIdValid).withMessage('Should have an playlist element id'), | 271 | .custom(isIdValid), |
270 | 272 | ||
271 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 273 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
272 | logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params }) | 274 | logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params }) |
@@ -300,13 +302,14 @@ const videoPlaylistElementAPGetValidator = [ | |||
300 | 302 | ||
301 | const videoPlaylistsReorderVideosValidator = [ | 303 | const videoPlaylistsReorderVideosValidator = [ |
302 | isValidPlaylistIdParam('playlistId'), | 304 | isValidPlaylistIdParam('playlistId'), |
305 | |||
303 | body('startPosition') | 306 | body('startPosition') |
304 | .isInt({ min: 1 }).withMessage('Should have a valid start position'), | 307 | .isInt({ min: 1 }), |
305 | body('insertAfterPosition') | 308 | body('insertAfterPosition') |
306 | .isInt({ min: 0 }).withMessage('Should have a valid insert after position'), | 309 | .isInt({ min: 0 }), |
307 | body('reorderLength') | 310 | body('reorderLength') |
308 | .optional() | 311 | .optional() |
309 | .isInt({ min: 1 }).withMessage('Should have a valid range length'), | 312 | .isInt({ min: 1 }), |
310 | 313 | ||
311 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 314 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
312 | logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params }) | 315 | logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params }) |
@@ -340,7 +343,7 @@ const videoPlaylistsReorderVideosValidator = [ | |||
340 | const commonVideoPlaylistFiltersValidator = [ | 343 | const commonVideoPlaylistFiltersValidator = [ |
341 | query('playlistType') | 344 | query('playlistType') |
342 | .optional() | 345 | .optional() |
343 | .custom(isVideoPlaylistTypeValid).withMessage('Should have a valid playlist type'), | 346 | .custom(isVideoPlaylistTypeValid), |
344 | 347 | ||
345 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 348 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
346 | logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params }) | 349 | logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params }) |
@@ -399,11 +402,11 @@ function getCommonPlaylistEditAttributes () { | |||
399 | body('description') | 402 | body('description') |
400 | .optional() | 403 | .optional() |
401 | .customSanitizer(toValueOrNull) | 404 | .customSanitizer(toValueOrNull) |
402 | .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'), | 405 | .custom(isVideoPlaylistDescriptionValid), |
403 | body('privacy') | 406 | body('privacy') |
404 | .optional() | 407 | .optional() |
405 | .customSanitizer(toIntOrNull) | 408 | .customSanitizer(toIntOrNull) |
406 | .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'), | 409 | .custom(isVideoPlaylistPrivacyValid), |
407 | body('videoChannelId') | 410 | body('videoChannelId') |
408 | .optional() | 411 | .optional() |
409 | .customSanitizer(toIntOrNull) | 412 | .customSanitizer(toIntOrNull) |