aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-10 11:27:14 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-10 11:27:14 +0100
commitf6f7dfee01e8b7ddf62d2549b8f381d0b12b590e (patch)
treedf99579a701d40b02e495c76337a6d266f60dcc6 /server/helpers/custom-validators
parentc70e0710b39b45e1b8b2d043e3d94f59df16b8a8 (diff)
downloadPeerTube-f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e.tar.gz
PeerTube-f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e.tar.zst
PeerTube-f6f7dfee01e8b7ddf62d2549b8f381d0b12b590e.zip
Server: update express-validator
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/videos.js18
1 files changed, 17 insertions, 1 deletions
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 = {
21 isVideoExtnameValid, 21 isVideoExtnameValid,
22 isVideoRemoteIdValid, 22 isVideoRemoteIdValid,
23 isVideoAbuseReasonValid, 23 isVideoAbuseReasonValid,
24 isVideoAbuseReporterUsernameValid 24 isVideoAbuseReporterUsernameValid,
25 isVideoFile
25} 26}
26 27
27function isVideoAuthorValid (value) { 28function isVideoAuthorValid (value) {
@@ -81,6 +82,21 @@ function isVideoAbuseReporterUsernameValid (value) {
81 return usersValidators.isUserUsernameValid(value) 82 return usersValidators.isUserUsernameValid(value)
82} 83}
83 84
85function isVideoFile (value, files) {
86 // Should have files
87 if (!files) return false
88
89 // Should have videofile file
90 const videofile = files.videofile
91 if (!videofile || videofile.length === 0) return false
92
93 // The file should exist
94 const file = videofile[0]
95 if (!file || !file.originalname) return false
96
97 return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype)
98}
99
84// --------------------------------------------------------------------------- 100// ---------------------------------------------------------------------------
85 101
86module.exports = videosValidators 102module.exports = videosValidators