+const removeVideoCommentValidator = [
+ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
+ param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params })
+
+ if (areValidationErrors(req, res)) return
+ if (!await isVideoExist(req.params.videoId, res)) return
+ if (!await isVideoCommentExist(req.params.commentId, res.locals.video, res)) return
+
+ // Check if the user who did the request is able to delete the video
+ if (!checkUserCanDeleteVideoComment(res.locals.oauth.token.User, res.locals.videoComment, res)) return
+
+ return next()
+ }
+]
+