aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos/video-channels.ts')
-rw-r--r--server/middlewares/validators/videos/video-channels.ts38
1 files changed, 25 insertions, 13 deletions
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index d53c777fa..ad1415691 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -19,10 +19,16 @@ import { areValidationErrors, checkUserQuota, doesVideoChannelNameWithHostExist
19import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs' 19import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs'
20 20
21export const videoChannelsAddValidator = [ 21export const videoChannelsAddValidator = [
22 body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), 22 body('name')
23 body('displayName').custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), 23 .custom(isVideoChannelUsernameValid),
24 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 24 body('displayName')
25 body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), 25 .custom(isVideoChannelDisplayNameValid),
26 body('description')
27 .optional()
28 .custom(isVideoChannelDescriptionValid),
29 body('support')
30 .optional()
31 .custom(isVideoChannelSupportValid),
26 32
27 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 33 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
28 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body }) 34 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })
@@ -49,16 +55,18 @@ export const videoChannelsAddValidator = [
49] 55]
50 56
51export const videoChannelsUpdateValidator = [ 57export const videoChannelsUpdateValidator = [
52 param('nameWithHost').exists().withMessage('Should have an video channel name with host'), 58 param('nameWithHost')
59 .exists(),
60
53 body('displayName') 61 body('displayName')
54 .optional() 62 .optional()
55 .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'), 63 .custom(isVideoChannelDisplayNameValid),
56 body('description') 64 body('description')
57 .optional() 65 .optional()
58 .custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 66 .custom(isVideoChannelDescriptionValid),
59 body('support') 67 body('support')
60 .optional() 68 .optional()
61 .custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), 69 .custom(isVideoChannelSupportValid),
62 body('bulkVideosSupportUpdate') 70 body('bulkVideosSupportUpdate')
63 .optional() 71 .optional()
64 .custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'), 72 .custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'),
@@ -83,7 +91,8 @@ export const videoChannelsRemoveValidator = [
83] 91]
84 92
85export const videoChannelsNameWithHostValidator = [ 93export const videoChannelsNameWithHostValidator = [
86 param('nameWithHost').exists().withMessage('Should have an video channel name with host'), 94 param('nameWithHost')
95 .exists(),
87 96
88 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 97 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
89 logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params }) 98 logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params })
@@ -124,7 +133,7 @@ export const videoChannelStatsValidator = [
124 query('withStats') 133 query('withStats')
125 .optional() 134 .optional()
126 .customSanitizer(toBooleanOrNull) 135 .customSanitizer(toBooleanOrNull)
127 .custom(isBooleanValid).withMessage('Should have a valid stats flag'), 136 .custom(isBooleanValid).withMessage('Should have a valid stats flag boolean'),
128 137
129 (req: express.Request, res: express.Response, next: express.NextFunction) => { 138 (req: express.Request, res: express.Response, next: express.NextFunction) => {
130 if (areValidationErrors(req, res)) return 139 if (areValidationErrors(req, res)) return
@@ -133,7 +142,9 @@ export const videoChannelStatsValidator = [
133] 142]
134 143
135export const videoChannelsListValidator = [ 144export const videoChannelsListValidator = [
136 query('search').optional().not().isEmpty().withMessage('Should have a valid search'), 145 query('search')
146 .optional()
147 .not().isEmpty(),
137 148
138 (req: express.Request, res: express.Response, next: express.NextFunction) => { 149 (req: express.Request, res: express.Response, next: express.NextFunction) => {
139 logger.debug('Checking video channels search query', { parameters: req.query }) 150 logger.debug('Checking video channels search query', { parameters: req.query })
@@ -145,11 +156,12 @@ export const videoChannelsListValidator = [
145] 156]
146 157
147export const videoChannelImportVideosValidator = [ 158export const videoChannelImportVideosValidator = [
148 body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'), 159 body('externalChannelUrl')
160 .custom(isUrlValid),
149 161
150 body('videoChannelSyncId') 162 body('videoChannelSyncId')
151 .optional() 163 .optional()
152 .custom(isIdValid).withMessage('Should have a valid channel sync id'), 164 .custom(isIdValid),
153 165
154 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 166 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
155 logger.debug('Checking videoChannelImport parameters', { parameters: req.body }) 167 logger.debug('Checking videoChannelImport parameters', { parameters: req.body })