parent
70330f6323
commit
7dab0bd698
|
@ -33,7 +33,9 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([
|
||||||
),
|
),
|
||||||
body('name')
|
body('name')
|
||||||
.optional()
|
.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) => {
|
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||||
logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body })
|
logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body })
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { VideoModel } from '@server/models/video/video'
|
||||||
import { Hooks } from '@server/lib/plugins/hooks'
|
import { Hooks } from '@server/lib/plugins/hooks'
|
||||||
import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
|
import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
|
||||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||||
|
import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
|
||||||
|
|
||||||
const videoLiveGetValidator = [
|
const videoLiveGetValidator = [
|
||||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
|
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'),
|
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
||||||
|
|
||||||
body('name')
|
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')
|
body('saveReplay')
|
||||||
.optional()
|
.optional()
|
||||||
|
|
|
@ -65,8 +65,9 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
|
||||||
.withMessage('Should have a file'),
|
.withMessage('Should have a file'),
|
||||||
body('name')
|
body('name')
|
||||||
.trim()
|
.trim()
|
||||||
.custom(isVideoNameValid)
|
.custom(isVideoNameValid).withMessage(
|
||||||
.withMessage('Should have a valid name'),
|
`Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`
|
||||||
|
),
|
||||||
body('channelId')
|
body('channelId')
|
||||||
.customSanitizer(toIntOrNull)
|
.customSanitizer(toIntOrNull)
|
||||||
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
||||||
|
@ -146,8 +147,9 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([
|
||||||
.withMessage('Should have a valid filename'),
|
.withMessage('Should have a valid filename'),
|
||||||
body('name')
|
body('name')
|
||||||
.trim()
|
.trim()
|
||||||
.custom(isVideoNameValid)
|
.custom(isVideoNameValid).withMessage(
|
||||||
.withMessage('Should have a valid name'),
|
`Should have a video name between ${CONSTRAINTS_FIELDS.VIDEOS.NAME.min} and ${CONSTRAINTS_FIELDS.VIDEOS.NAME.max} characters long`
|
||||||
|
),
|
||||||
body('channelId')
|
body('channelId')
|
||||||
.customSanitizer(toIntOrNull)
|
.customSanitizer(toIntOrNull)
|
||||||
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
||||||
|
@ -196,7 +198,9 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
|
||||||
body('name')
|
body('name')
|
||||||
.optional()
|
.optional()
|
||||||
.trim()
|
.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')
|
body('channelId')
|
||||||
.optional()
|
.optional()
|
||||||
.customSanitizer(toIntOrNull)
|
.customSanitizer(toIntOrNull)
|
||||||
|
@ -455,7 +459,11 @@ function getCommonVideoEditAttributes () {
|
||||||
body('tags')
|
body('tags')
|
||||||
.optional()
|
.optional()
|
||||||
.customSanitizer(toValueOrNull)
|
.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')
|
body('commentsEnabled')
|
||||||
.optional()
|
.optional()
|
||||||
.customSanitizer(toBooleanOrNull)
|
.customSanitizer(toBooleanOrNull)
|
||||||
|
|
Loading…
Reference in New Issue