aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos/videos.ts')
-rw-r--r--server/middlewares/validators/videos/videos.ts20
1 files changed, 14 insertions, 6 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index dce02df18..8864be269 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -65,8 +65,9 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
65 .withMessage('Should have a file'), 65 .withMessage('Should have a file'),
66 body('name') 66 body('name')
67 .trim() 67 .trim()
68 .custom(isVideoNameValid) 68 .custom(isVideoNameValid).withMessage(
69 .withMessage('Should have a valid name'), 69 `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`
70 ),
70 body('channelId') 71 body('channelId')
71 .customSanitizer(toIntOrNull) 72 .customSanitizer(toIntOrNull)
72 .custom(isIdValid).withMessage('Should have correct video channel id'), 73 .custom(isIdValid).withMessage('Should have correct video channel id'),
@@ -146,8 +147,9 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([
146 .withMessage('Should have a valid filename'), 147 .withMessage('Should have a valid filename'),
147 body('name') 148 body('name')
148 .trim() 149 .trim()
149 .custom(isVideoNameValid) 150 .custom(isVideoNameValid).withMessage(
150 .withMessage('Should have a valid name'), 151 `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`
152 ),
151 body('channelId') 153 body('channelId')
152 .customSanitizer(toIntOrNull) 154 .customSanitizer(toIntOrNull)
153 .custom(isIdValid).withMessage('Should have correct video channel id'), 155 .custom(isIdValid).withMessage('Should have correct video channel id'),
@@ -196,7 +198,9 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
196 body('name') 198 body('name')
197 .optional() 199 .optional()
198 .trim() 200 .trim()
199 .custom(isVideoNameValid).withMessage('Should have a valid name'), 201 .custom(isVideoNameValid).withMessage(
202 `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`
203 ),
200 body('channelId') 204 body('channelId')
201 .optional() 205 .optional()
202 .customSanitizer(toIntOrNull) 206 .customSanitizer(toIntOrNull)
@@ -455,7 +459,11 @@ function getCommonVideoEditAttributes () {
455 body('tags') 459 body('tags')
456 .optional() 460 .optional()
457 .customSanitizer(toValueOrNull) 461 .customSanitizer(toValueOrNull)
458 .custom(isVideoTagsValid).withMessage('Should have correct tags'), 462 .custom(isVideoTagsValid)
463 .withMessage(
464 `Should have an array of up to ${CONSTRAINTS_FIELDS.VIDEOS.TAGS.max} tags between ` +
465 `${CONSTRAINTS_FIELDS.VIDEOS.TAG.min} and ${CONSTRAINTS_FIELDS.VIDEOS.TAG.max} characters each`
466 ),
459 body('commentsEnabled') 467 body('commentsEnabled')
460 .optional() 468 .optional()
461 .customSanitizer(toBooleanOrNull) 469 .customSanitizer(toBooleanOrNull)