]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/videos.ts
Upgrade express validator to v4
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / videos.ts
index 1d27e47fc392a57c4a04057c16ac8569cfc43cba..2eb021ae7ba4e096ee0a0fcc60c57f9275b9f6f0 100644 (file)
@@ -107,12 +107,13 @@ function isVideoRatingTypeValid (value: string) {
   return values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1
 }
 
-function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) {
+function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) {
   // Should have files
   if (!files) return false
+  if (isArray(files)) return false
 
   // Should have videofile file
-  const videofile = files.videofile
+  const videofile = files['videofile']
   if (!videofile || videofile.length === 0) return false
 
   // The file should exist
@@ -168,34 +169,3 @@ export {
   isVideoFileSizeValid,
   isVideoFileResolutionValid
 }
-
-declare module 'express-validator' {
-  export interface Validator {
-    isVideoIdOrUUIDValid,
-    isVideoAuthorValid,
-    isVideoDateValid,
-    isVideoCategoryValid,
-    isVideoLicenceValid,
-    isVideoLanguageValid,
-    isVideoNSFWValid,
-    isVideoDescriptionValid,
-    isVideoDurationValid,
-    isVideoInfoHashValid,
-    isVideoNameValid,
-    isVideoTagsValid,
-    isVideoThumbnailValid,
-    isVideoThumbnailDataValid,
-    isVideoExtnameValid,
-    isVideoUUIDValid,
-    isVideoAbuseReasonValid,
-    isVideoAbuseReporterUsernameValid,
-    isVideoFile,
-    isVideoViewsValid,
-    isVideoLikesValid,
-    isVideoRatingTypeValid,
-    isVideoDislikesValid,
-    isVideoEventCountValid,
-    isVideoFileSizeValid,
-    isVideoFileResolutionValid
-  }
-}