]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/videos.ts
Add lazy description on server
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / videos.ts
index 05d1dc60744eac1457d496f2afa3383f7584e278..5b9102275cebac16b4d7e5d842441f3efbdc3406 100644 (file)
@@ -23,34 +23,41 @@ const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
 const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
 const VIDEO_EVENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_EVENTS
 
-function isVideoIdOrUUIDValid (value: string) {
-  return validator.isInt(value) || isVideoUUIDValid(value)
-}
-
-function isVideoAuthorValid (value: string) {
-  return isUserUsernameValid(value)
-}
-
-function isVideoDateValid (value: string) {
-  return exists(value) && validator.isISO8601(value)
-}
-
 function isVideoCategoryValid (value: number) {
   return VIDEO_CATEGORIES[value] !== undefined
 }
 
+// Maybe we don't know the remote category, but that doesn't matter
+function isRemoteVideoCategoryValid (value: string) {
+  return validator.isInt('' + value)
+}
+
 function isVideoLicenceValid (value: number) {
   return VIDEO_LICENCES[value] !== undefined
 }
 
+// Maybe we don't know the remote licence, but that doesn't matter
+function isRemoteVideoLicenceValid (value: string) {
+  return validator.isInt('' + value)
+}
+
 function isVideoLanguageValid (value: number) {
   return value === null || VIDEO_LANGUAGES[value] !== undefined
 }
 
+// Maybe we don't know the remote language, but that doesn't matter
+function isRemoteVideoLanguageValid (value: string) {
+  return validator.isInt('' + value)
+}
+
 function isVideoNSFWValid (value: any) {
   return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
 }
 
+function isVideoTruncatedDescriptionValid (value: string) {
+  return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION)
+}
+
 function isVideoDescriptionValid (value: string) {
   return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)
 }
@@ -79,10 +86,6 @@ function isVideoThumbnailDataValid (value: string) {
   return exists(value) && validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA)
 }
 
-function isVideoUUIDValid (value: string) {
-  return exists(value) && validator.isUUID('' + value, 4)
-}
-
 function isVideoAbuseReasonValid (value: string) {
   return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON)
 }
@@ -170,13 +173,11 @@ function checkVideoExists (id: string, res: express.Response, callback: () => vo
 // ---------------------------------------------------------------------------
 
 export {
-  isVideoIdOrUUIDValid,
-  isVideoAuthorValid,
-  isVideoDateValid,
   isVideoCategoryValid,
   isVideoLicenceValid,
   isVideoLanguageValid,
   isVideoNSFWValid,
+  isVideoTruncatedDescriptionValid,
   isVideoDescriptionValid,
   isVideoDurationValid,
   isVideoFileInfoHashValid,
@@ -185,7 +186,6 @@ export {
   isVideoThumbnailValid,
   isVideoThumbnailDataValid,
   isVideoFileExtnameValid,
-  isVideoUUIDValid,
   isVideoAbuseReasonValid,
   isVideoAbuseReporterUsernameValid,
   isVideoFile,
@@ -196,5 +196,8 @@ export {
   isVideoEventCountValid,
   isVideoFileSizeValid,
   isVideoFileResolutionValid,
-  checkVideoExists
+  checkVideoExists,
+  isRemoteVideoCategoryValid,
+  isRemoteVideoLicenceValid,
+  isRemoteVideoLanguageValid
 }