aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-15 14:46:26 +0100
committerChocobozzz <me@florianbigard.com>2018-02-15 15:29:07 +0100
commit2422c46b27790d94fd29a7092170cee5a1b56008 (patch)
treed5c1942ce20cadb27a551d87c789edfe92f5b105 /server/middlewares/validators
parent34cbef8c6cc912143a421413bdd832c4adcc556a (diff)
downloadPeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip
Implement support field in video and video channel
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/users.ts2
-rw-r--r--server/middlewares/validators/video-channels.ts6
-rw-r--r--server/middlewares/validators/videos.ts4
3 files changed, 9 insertions, 3 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index cba15c8d3..49bc0bb56 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -7,6 +7,7 @@ import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
7import { 7import {
8 isAvatarFile, 8 isAvatarFile,
9 isUserAutoPlayVideoValid, 9 isUserAutoPlayVideoValid,
10 isUserDescriptionValid,
10 isUserDisplayNSFWValid, 11 isUserDisplayNSFWValid,
11 isUserPasswordValid, 12 isUserPasswordValid,
12 isUserRoleValid, 13 isUserRoleValid,
@@ -97,6 +98,7 @@ const usersUpdateValidator = [
97] 98]
98 99
99const usersUpdateMeValidator = [ 100const usersUpdateMeValidator = [
101 body('description').optional().custom(isUserDescriptionValid).withMessage('Should have a valid description'),
100 body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), 102 body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'),
101 body('email').optional().isEmail().withMessage('Should have a valid email attribute'), 103 body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
102 body('displayNSFW').optional().custom(isUserDisplayNSFWValid).withMessage('Should have a valid display Not Safe For Work attribute'), 104 body('displayNSFW').optional().custom(isUserDisplayNSFWValid).withMessage('Should have a valid display Not Safe For Work attribute'),
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts
index 86bddde82..fe42105e8 100644
--- a/server/middlewares/validators/video-channels.ts
+++ b/server/middlewares/validators/video-channels.ts
@@ -5,7 +5,7 @@ import { isAccountIdExist } from '../../helpers/custom-validators/accounts'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
6import { 6import {
7 isVideoChannelDescriptionValid, isVideoChannelExist, 7 isVideoChannelDescriptionValid, isVideoChannelExist,
8 isVideoChannelNameValid 8 isVideoChannelNameValid, isVideoChannelSupportValid
9} from '../../helpers/custom-validators/video-channels' 9} from '../../helpers/custom-validators/video-channels'
10import { logger } from '../../helpers/logger' 10import { logger } from '../../helpers/logger'
11import { UserModel } from '../../models/account/user' 11import { UserModel } from '../../models/account/user'
@@ -27,7 +27,8 @@ const listVideoAccountChannelsValidator = [
27 27
28const videoChannelsAddValidator = [ 28const videoChannelsAddValidator = [
29 body('name').custom(isVideoChannelNameValid).withMessage('Should have a valid name'), 29 body('name').custom(isVideoChannelNameValid).withMessage('Should have a valid name'),
30 body('description').custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 30 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),
31 body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),
31 32
32 (req: express.Request, res: express.Response, next: express.NextFunction) => { 33 (req: express.Request, res: express.Response, next: express.NextFunction) => {
33 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body }) 34 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })
@@ -42,6 +43,7 @@ const videoChannelsUpdateValidator = [
42 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), 43 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
43 body('name').optional().custom(isVideoChannelNameValid).withMessage('Should have a valid name'), 44 body('name').optional().custom(isVideoChannelNameValid).withMessage('Should have a valid name'),
44 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 45 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),
46 body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),
45 47
46 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 48 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
47 logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body }) 49 logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index 6d4fb907b..e91739f81 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -14,7 +14,7 @@ import {
14 isVideoLicenceValid, 14 isVideoLicenceValid,
15 isVideoNameValid, 15 isVideoNameValid,
16 isVideoPrivacyValid, 16 isVideoPrivacyValid,
17 isVideoRatingTypeValid, 17 isVideoRatingTypeValid, isVideoSupportValid,
18 isVideoTagsValid 18 isVideoTagsValid
19} from '../../helpers/custom-validators/videos' 19} from '../../helpers/custom-validators/videos'
20import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' 20import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils'
@@ -46,6 +46,7 @@ const videosAddValidator = [
46 body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'), 46 body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'),
47 body('nsfw').custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), 47 body('nsfw').custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
48 body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), 48 body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'),
49 body('support').optional().custom(isVideoSupportValid).withMessage('Should have a valid support text'),
49 body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'), 50 body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'),
50 body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), 51 body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
51 body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), 52 body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'),
@@ -116,6 +117,7 @@ const videosUpdateValidator = [
116 body('nsfw').optional().custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), 117 body('nsfw').optional().custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
117 body('privacy').optional().custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), 118 body('privacy').optional().custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
118 body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), 119 body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'),
120 body('support').optional().custom(isVideoSupportValid).withMessage('Should have a valid support text'),
119 body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), 121 body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'),
120 body('commentsEnabled').optional().custom(isBooleanValid).withMessage('Should have comments enabled boolean'), 122 body('commentsEnabled').optional().custom(isBooleanValid).withMessage('Should have comments enabled boolean'),
121 123