aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos.ts')
-rw-r--r--server/middlewares/validators/videos.ts45
1 files changed, 25 insertions, 20 deletions
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index 5595edf17..59d65d5a4 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -38,18 +38,21 @@ import { authenticate } from '../oauth'
38import { areValidationErrors } from './utils' 38import { areValidationErrors } from './utils'
39 39
40const videosAddValidator = [ 40const videosAddValidator = [
41 body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage( 41 body('videofile')
42 'This file is not supported. Please, make sure it is of the following type : ' 42 .custom((value, { req }) => isVideoFile(req.files)).withMessage(
43 + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ') 43 'This file is not supported or too large. Please, make sure it is of the following type : '
44 ), 44 + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ')
45 body('thumbnailfile').custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage( 45 ),
46 'This thumbnail file is not supported. Please, make sure it is of the following type : ' 46 body('thumbnailfile')
47 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 47 .custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
48 ), 48 'This thumbnail file is not supported or too large. Please, make sure it is of the following type : '
49 body('previewfile').custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage( 49 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
50 'This preview file is not supported. Please, make sure it is of the following type : ' 50 ),
51 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 51 body('previewfile')
52 ), 52 .custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
53 'This preview file is not supported or too large. Please, make sure it is of the following type : '
54 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
55 ),
53 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), 56 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
54 body('category') 57 body('category')
55 .optional() 58 .optional()
@@ -147,14 +150,16 @@ const videosAddValidator = [
147 150
148const videosUpdateValidator = [ 151const videosUpdateValidator = [
149 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), 152 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
150 body('thumbnailfile').custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage( 153 body('thumbnailfile')
151 'This thumbnail file is not supported. Please, make sure it is of the following type : ' 154 .custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
152 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 155 'This thumbnail file is not supported or too large. Please, make sure it is of the following type : '
153 ), 156 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
154 body('previewfile').custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage( 157 ),
155 'This preview file is not supported. Please, make sure it is of the following type : ' 158 body('previewfile')
156 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 159 .custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
157 ), 160 'This preview file is not supported or too large. Please, make sure it is of the following type : '
161 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
162 ),
158 body('name') 163 body('name')
159 .optional() 164 .optional()
160 .custom(isVideoNameValid).withMessage('Should have a valid name'), 165 .custom(isVideoNameValid).withMessage('Should have a valid name'),