From b60e5f38daf77e720a27aa86d3b482c58906a03a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Sep 2017 12:17:08 +0200 Subject: Upgrade express validator to v4 --- server/helpers/custom-validators/misc.ts | 7 ----- server/helpers/custom-validators/pods.ts | 7 ----- server/helpers/custom-validators/remote/videos.ts | 8 ----- server/helpers/custom-validators/users.ts | 10 ------- server/helpers/custom-validators/videos.ts | 36 ++--------------------- 5 files changed, 3 insertions(+), 65 deletions(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 8d215a416..60fcdd5bb 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -14,10 +14,3 @@ export { exists, isArray } - -declare module 'express-validator' { - export interface Validator { - exists, - isArray - } -} diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts index 844bfdf78..d5021bf38 100644 --- a/server/helpers/custom-validators/pods.ts +++ b/server/helpers/custom-validators/pods.ts @@ -32,10 +32,3 @@ export { isEachUniqueHostValid, isHostValid } - -declare module 'express-validator' { - export interface Validator { - isEachUniqueHostValid - isHostValid - } -} diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts index e5c76f3ca..e261e05a8 100644 --- a/server/helpers/custom-validators/remote/videos.ts +++ b/server/helpers/custom-validators/remote/videos.ts @@ -102,14 +102,6 @@ export { isEachRemoteRequestVideosEventsValid } -declare module 'express-validator' { - export interface Validator { - isEachRemoteRequestVideosValid, - isEachRemoteRequestVideosQaduValid, - isEachRemoteRequestVideosEventsValid - } -} - // --------------------------------------------------------------------------- function isCommonVideoAttributesValid (video: any) { diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 805437efa..c180eccda 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -39,13 +39,3 @@ export { isUserUsernameValid, isUserDisplayNSFWValid } - -declare module 'express-validator' { - export interface Validator { - isUserPasswordValid, - isUserRoleValid, - isUserUsernameValid, - isUserDisplayNSFWValid, - isUserVideoQuotaValid - } -} diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 1d27e47fc..2eb021ae7 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -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 - } -} -- cgit v1.2.3