import { areValidationErrors } from './utils'
const videosAddValidator = [
- body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage(
- 'This file is not supported. Please, make sure it is of the following type : '
- + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ')
- ),
- body('thumbnailfile').custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
- 'This thumbnail file is not supported. Please, make sure it is of the following type : '
- + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
- ),
- body('previewfile').custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
- 'This preview file is not supported. Please, make sure it is of the following type : '
- + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
- ),
+ body('videofile')
+ .custom((value, { req }) => isVideoFile(req.files)).withMessage(
+ 'This file is not supported or too large. Please, make sure it is of the following type : '
+ + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ')
+ ),
+ body('thumbnailfile')
+ .custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
+ 'This thumbnail file is not supported or too large. Please, make sure it is of the following type : '
+ + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
+ ),
+ body('previewfile')
+ .custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
+ 'This preview file is not supported or too large. Please, make sure it is of the following type : '
+ + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
+ ),
body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
body('category')
.optional()
const videosUpdateValidator = [
param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
- body('thumbnailfile').custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
- 'This thumbnail file is not supported. Please, make sure it is of the following type : '
- + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
- ),
- body('previewfile').custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
- 'This preview file is not supported. Please, make sure it is of the following type : '
- + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
- ),
+ body('thumbnailfile')
+ .custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
+ 'This thumbnail file is not supported or too large. Please, make sure it is of the following type : '
+ + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
+ ),
+ body('previewfile')
+ .custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
+ 'This preview file is not supported or too large. Please, make sure it is of the following type : '
+ + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
+ ),
body('name')
.optional()
.custom(isVideoNameValid).withMessage('Should have a valid name'),