diff options
Diffstat (limited to 'server/helpers/custom-validators/videos.ts')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 72d226e81..e335b09d1 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -17,6 +17,10 @@ const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS | |||
17 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES | 17 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES |
18 | const VIDEO_EVENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_EVENTS | 18 | const VIDEO_EVENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_EVENTS |
19 | 19 | ||
20 | function isVideoIdOrUUIDValid (value: string) { | ||
21 | return validator.isInt(value) || isVideoUUIDValid(value) | ||
22 | } | ||
23 | |||
20 | function isVideoAuthorValid (value: string) { | 24 | function isVideoAuthorValid (value: string) { |
21 | return isUserUsernameValid(value) | 25 | return isUserUsernameValid(value) |
22 | } | 26 | } |
@@ -77,8 +81,8 @@ function isVideoThumbnailDataValid (value: string) { | |||
77 | return exists(value) && validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA) | 81 | return exists(value) && validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA) |
78 | } | 82 | } |
79 | 83 | ||
80 | function isVideoRemoteIdValid (value: string) { | 84 | function isVideoUUIDValid (value: string) { |
81 | return exists(value) && validator.isUUID(value, 4) | 85 | return exists(value) && validator.isUUID('' + value, 4) |
82 | } | 86 | } |
83 | 87 | ||
84 | function isVideoAbuseReasonValid (value: string) { | 88 | function isVideoAbuseReasonValid (value: string) { |
@@ -127,6 +131,7 @@ function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Mul | |||
127 | // --------------------------------------------------------------------------- | 131 | // --------------------------------------------------------------------------- |
128 | 132 | ||
129 | export { | 133 | export { |
134 | isVideoIdOrUUIDValid, | ||
130 | isVideoAuthorValid, | 135 | isVideoAuthorValid, |
131 | isVideoDateValid, | 136 | isVideoDateValid, |
132 | isVideoCategoryValid, | 137 | isVideoCategoryValid, |
@@ -141,7 +146,7 @@ export { | |||
141 | isVideoThumbnailValid, | 146 | isVideoThumbnailValid, |
142 | isVideoThumbnailDataValid, | 147 | isVideoThumbnailDataValid, |
143 | isVideoExtnameValid, | 148 | isVideoExtnameValid, |
144 | isVideoRemoteIdValid, | 149 | isVideoUUIDValid, |
145 | isVideoAbuseReasonValid, | 150 | isVideoAbuseReasonValid, |
146 | isVideoAbuseReporterUsernameValid, | 151 | isVideoAbuseReporterUsernameValid, |
147 | isVideoFile, | 152 | isVideoFile, |
@@ -155,6 +160,7 @@ export { | |||
155 | declare global { | 160 | declare global { |
156 | namespace ExpressValidator { | 161 | namespace ExpressValidator { |
157 | export interface Validator { | 162 | export interface Validator { |
163 | isVideoIdOrUUIDValid, | ||
158 | isVideoAuthorValid, | 164 | isVideoAuthorValid, |
159 | isVideoDateValid, | 165 | isVideoDateValid, |
160 | isVideoCategoryValid, | 166 | isVideoCategoryValid, |
@@ -169,7 +175,7 @@ declare global { | |||
169 | isVideoThumbnailValid, | 175 | isVideoThumbnailValid, |
170 | isVideoThumbnailDataValid, | 176 | isVideoThumbnailDataValid, |
171 | isVideoExtnameValid, | 177 | isVideoExtnameValid, |
172 | isVideoRemoteIdValid, | 178 | isVideoUUIDValid, |
173 | isVideoAbuseReasonValid, | 179 | isVideoAbuseReasonValid, |
174 | isVideoAbuseReporterUsernameValid, | 180 | isVideoAbuseReporterUsernameValid, |
175 | isVideoFile, | 181 | isVideoFile, |