diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-08-25 18:36:49 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-08-25 18:36:49 +0200 |
commit | 556ddc319242aafef51bae9301423ecf8701a3af (patch) | |
tree | 413829b522193584df348f0356a702b3222c3419 /server/helpers/custom-validators | |
parent | d15ab38a905e6b50972e6f884917db9198279daf (diff) | |
download | PeerTube-556ddc319242aafef51bae9301423ecf8701a3af.tar.gz PeerTube-556ddc319242aafef51bae9301423ecf8701a3af.tar.zst PeerTube-556ddc319242aafef51bae9301423ecf8701a3af.zip |
Upgrade common server dependencies
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/misc.ts | 10 | ||||
-rw-r--r-- | server/helpers/custom-validators/pods.ts | 23 | ||||
-rw-r--r-- | server/helpers/custom-validators/remote/videos.ts | 12 | ||||
-rw-r--r-- | server/helpers/custom-validators/users.ts | 14 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 58 |
5 files changed, 59 insertions, 58 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index b1291ba7a..f6bb02c8e 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -13,11 +13,9 @@ export { | |||
13 | isArray | 13 | isArray |
14 | } | 14 | } |
15 | 15 | ||
16 | declare global { | 16 | declare module 'express-validator' { |
17 | namespace ExpressValidator { | 17 | export interface Validator { |
18 | export interface Validator { | 18 | exists, |
19 | exists, | 19 | isArray |
20 | isArray | ||
21 | } | ||
22 | } | 20 | } |
23 | } | 21 | } |
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts index 0519def52..f2ca520c0 100644 --- a/server/helpers/custom-validators/pods.ts +++ b/server/helpers/custom-validators/pods.ts | |||
@@ -1,9 +1,20 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | 2 | ||
3 | import { isArray, exists } from './misc' | 3 | import { isArray, exists } from './misc' |
4 | import { isTestInstance } from '../core-utils' | ||
4 | 5 | ||
5 | function isHostValid (host: string) { | 6 | function isHostValid (host: string) { |
6 | return exists(host) && validator.isURL(host) && host.split('://').length === 1 | 7 | const isURLOptions = { |
8 | require_host: true, | ||
9 | require_tld: true | ||
10 | } | ||
11 | |||
12 | // We validate 'localhost', so we don't have the top level domain | ||
13 | if (isTestInstance()) { | ||
14 | isURLOptions.require_tld = false | ||
15 | } | ||
16 | |||
17 | return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1 | ||
7 | } | 18 | } |
8 | 19 | ||
9 | function isEachUniqueHostValid (hosts: string[]) { | 20 | function isEachUniqueHostValid (hosts: string[]) { |
@@ -21,11 +32,9 @@ export { | |||
21 | isHostValid | 32 | isHostValid |
22 | } | 33 | } |
23 | 34 | ||
24 | declare global { | 35 | declare module 'express-validator' { |
25 | namespace ExpressValidator { | 36 | export interface Validator { |
26 | export interface Validator { | 37 | isEachUniqueHostValid |
27 | isEachUniqueHostValid | 38 | isHostValid |
28 | isHostValid | ||
29 | } | ||
30 | } | 39 | } |
31 | } | 40 | } |
diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts index 091cd2186..49f76e909 100644 --- a/server/helpers/custom-validators/remote/videos.ts +++ b/server/helpers/custom-validators/remote/videos.ts | |||
@@ -101,13 +101,11 @@ export { | |||
101 | isEachRemoteRequestVideosEventsValid | 101 | isEachRemoteRequestVideosEventsValid |
102 | } | 102 | } |
103 | 103 | ||
104 | declare global { | 104 | declare module 'express-validator' { |
105 | namespace ExpressValidator { | 105 | export interface Validator { |
106 | export interface Validator { | 106 | isEachRemoteRequestVideosValid, |
107 | isEachRemoteRequestVideosValid, | 107 | isEachRemoteRequestVideosQaduValid, |
108 | isEachRemoteRequestVideosQaduValid, | 108 | isEachRemoteRequestVideosEventsValid |
109 | isEachRemoteRequestVideosEventsValid | ||
110 | } | ||
111 | } | 109 | } |
112 | } | 110 | } |
113 | 111 | ||
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 750563ada..2b37bdde8 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -34,13 +34,11 @@ export { | |||
34 | isUserDisplayNSFWValid | 34 | isUserDisplayNSFWValid |
35 | } | 35 | } |
36 | 36 | ||
37 | declare global { | 37 | declare module 'express-validator' { |
38 | namespace ExpressValidator { | 38 | export interface Validator { |
39 | export interface Validator { | 39 | isUserPasswordValid, |
40 | isUserPasswordValid, | 40 | isUserRoleValid, |
41 | isUserRoleValid, | 41 | isUserUsernameValid, |
42 | isUserUsernameValid, | 42 | isUserDisplayNSFWValid |
43 | isUserDisplayNSFWValid | ||
44 | } | ||
45 | } | 43 | } |
46 | } | 44 | } |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 139fa760f..8b3a26644 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -168,35 +168,33 @@ export { | |||
168 | isVideoFileResolutionValid | 168 | isVideoFileResolutionValid |
169 | } | 169 | } |
170 | 170 | ||
171 | declare global { | 171 | declare module 'express-validator' { |
172 | namespace ExpressValidator { | 172 | export interface Validator { |
173 | export interface Validator { | 173 | isVideoIdOrUUIDValid, |
174 | isVideoIdOrUUIDValid, | 174 | isVideoAuthorValid, |
175 | isVideoAuthorValid, | 175 | isVideoDateValid, |
176 | isVideoDateValid, | 176 | isVideoCategoryValid, |
177 | isVideoCategoryValid, | 177 | isVideoLicenceValid, |
178 | isVideoLicenceValid, | 178 | isVideoLanguageValid, |
179 | isVideoLanguageValid, | 179 | isVideoNSFWValid, |
180 | isVideoNSFWValid, | 180 | isVideoDescriptionValid, |
181 | isVideoDescriptionValid, | 181 | isVideoDurationValid, |
182 | isVideoDurationValid, | 182 | isVideoInfoHashValid, |
183 | isVideoInfoHashValid, | 183 | isVideoNameValid, |
184 | isVideoNameValid, | 184 | isVideoTagsValid, |
185 | isVideoTagsValid, | 185 | isVideoThumbnailValid, |
186 | isVideoThumbnailValid, | 186 | isVideoThumbnailDataValid, |
187 | isVideoThumbnailDataValid, | 187 | isVideoExtnameValid, |
188 | isVideoExtnameValid, | 188 | isVideoUUIDValid, |
189 | isVideoUUIDValid, | 189 | isVideoAbuseReasonValid, |
190 | isVideoAbuseReasonValid, | 190 | isVideoAbuseReporterUsernameValid, |
191 | isVideoAbuseReporterUsernameValid, | 191 | isVideoFile, |
192 | isVideoFile, | 192 | isVideoViewsValid, |
193 | isVideoViewsValid, | 193 | isVideoLikesValid, |
194 | isVideoLikesValid, | 194 | isVideoRatingTypeValid, |
195 | isVideoRatingTypeValid, | 195 | isVideoDislikesValid, |
196 | isVideoDislikesValid, | 196 | isVideoEventCountValid, |
197 | isVideoEventCountValid, | 197 | isVideoFileSizeValid, |
198 | isVideoFileSizeValid, | 198 | isVideoFileResolutionValid |
199 | isVideoFileResolutionValid | ||
200 | } | ||
201 | } | 199 | } |
202 | } | 200 | } |