From f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Feb 2017 11:27:14 +0100 Subject: Server: update express-validator --- server/helpers/custom-validators/videos.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'server/helpers/custom-validators/videos.js') diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 7f727854d..e2d2c8e6d 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js @@ -21,7 +21,8 @@ const videosValidators = { isVideoExtnameValid, isVideoRemoteIdValid, isVideoAbuseReasonValid, - isVideoAbuseReporterUsernameValid + isVideoAbuseReporterUsernameValid, + isVideoFile } function isVideoAuthorValid (value) { @@ -81,6 +82,21 @@ function isVideoAbuseReporterUsernameValid (value) { return usersValidators.isUserUsernameValid(value) } +function isVideoFile (value, files) { + // Should have files + if (!files) return false + + // Should have videofile file + const videofile = files.videofile + if (!videofile || videofile.length === 0) return false + + // The file should exist + const file = videofile[0] + if (!file || !file.originalname) return false + + return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype) +} + // --------------------------------------------------------------------------- module.exports = videosValidators -- cgit v1.2.3