aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-15 16:28:35 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit8e10cf1a5a438a00e5f7e0691cb830769867cffc (patch)
tree23c0aeb43d7fb05b2d280c37b4334c2f320b647e /server/helpers/custom-validators/videos.ts
parent8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391 (diff)
downloadPeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.tar.gz
PeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.tar.zst
PeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.zip
Fix video upload and videos list
Diffstat (limited to 'server/helpers/custom-validators/videos.ts')
-rw-r--r--server/helpers/custom-validators/videos.ts15
1 files changed, 5 insertions, 10 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 1505632da..c97c9a2ad 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -69,6 +69,10 @@ function isVideoNSFWValid (value: any) {
69 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) 69 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
70} 70}
71 71
72function isVideoDurationValid (value: string) {
73 return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION)
74}
75
72function isVideoTruncatedDescriptionValid (value: string) { 76function isVideoTruncatedDescriptionValid (value: string) {
73 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION) 77 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION)
74} 78}
@@ -77,15 +81,6 @@ function isVideoDescriptionValid (value: string) {
77 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION) 81 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)
78} 82}
79 83
80function isVideoDurationValid (value: string) {
81 // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
82 return exists(value) &&
83 typeof value === 'string' &&
84 value.startsWith('PT') &&
85 value.endsWith('S') &&
86 validator.isInt(value.replace(/[^0-9]+/, ''), VIDEOS_CONSTRAINTS_FIELDS.DURATION)
87}
88
89function isVideoNameValid (value: string) { 84function isVideoNameValid (value: string) {
90 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) 85 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME)
91} 86}
@@ -197,7 +192,6 @@ export {
197 isVideoNSFWValid, 192 isVideoNSFWValid,
198 isVideoTruncatedDescriptionValid, 193 isVideoTruncatedDescriptionValid,
199 isVideoDescriptionValid, 194 isVideoDescriptionValid,
200 isVideoDurationValid,
201 isVideoFileInfoHashValid, 195 isVideoFileInfoHashValid,
202 isVideoNameValid, 196 isVideoNameValid,
203 isVideoTagsValid, 197 isVideoTagsValid,
@@ -214,6 +208,7 @@ export {
214 isVideoFileSizeValid, 208 isVideoFileSizeValid,
215 isVideoPrivacyValid, 209 isVideoPrivacyValid,
216 isRemoteVideoPrivacyValid, 210 isRemoteVideoPrivacyValid,
211 isVideoDurationValid,
217 isVideoFileResolutionValid, 212 isVideoFileResolutionValid,
218 checkVideoExists, 213 checkVideoExists,
219 isVideoTagValid, 214 isVideoTagValid,