diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts index d0643ff26..a5e3ffbcd 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/middlewares/validators/videos/video-imports.ts @@ -33,7 +33,9 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([ ), body('name') .optional() - .custom(isVideoNameValid).withMessage('Should have a valid name'), + .custom(isVideoNameValid).withMessage( + `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long` + ), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body }) diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts index 3a73e1272..ec4c7f32f 100644 --- a/server/middlewares/validators/videos/video-live.ts +++ b/server/middlewares/validators/videos/video-live.ts @@ -14,6 +14,7 @@ import { VideoModel } from '@server/models/video/video' import { Hooks } from '@server/lib/plugins/hooks' import { isLocalLiveVideoAccepted } from '@server/lib/moderation' import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' const videoLiveGetValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), @@ -43,7 +44,9 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ .custom(isIdValid).withMessage('Should have correct video channel id'), body('name') - .custom(isVideoNameValid).withMessage('Should have a valid name'), + .custom(isVideoNameValid).withMessage( + `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long` + ), body('saveReplay') .optional() 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([ .withMessage('Should have a file'), body('name') .trim() - .custom(isVideoNameValid) - .withMessage('Should have a valid name'), + .custom(isVideoNameValid).withMessage( + `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long` + ), body('channelId') .customSanitizer(toIntOrNull) .custom(isIdValid).withMessage('Should have correct video channel id'), @@ -146,8 +147,9 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([ .withMessage('Should have a valid filename'), body('name') .trim() - .custom(isVideoNameValid) - .withMessage('Should have a valid name'), + .custom(isVideoNameValid).withMessage( + `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long` + ), body('channelId') .customSanitizer(toIntOrNull) .custom(isIdValid).withMessage('Should have correct video channel id'), @@ -196,7 +198,9 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([ body('name') .optional() .trim() - .custom(isVideoNameValid).withMessage('Should have a valid name'), + .custom(isVideoNameValid).withMessage( + `Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long` + ), body('channelId') .optional() .customSanitizer(toIntOrNull) @@ -455,7 +459,11 @@ function getCommonVideoEditAttributes () { body('tags') .optional() .customSanitizer(toValueOrNull) - .custom(isVideoTagsValid).withMessage('Should have correct tags'), + .custom(isVideoTagsValid) + .withMessage( + `Should have an array of up to ${CONSTRAINTS_FIELDS.VIDEOS.TAGS.max} tags between ` + + `${CONSTRAINTS_FIELDS.VIDEOS.TAG.min} and ${CONSTRAINTS_FIELDS.VIDEOS.TAG.max} characters each` + ), body('commentsEnabled') .optional() .customSanitizer(toBooleanOrNull)