]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/videos.ts
Update iso639 translations for french and deutch
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / videos.ts
index 8496e679aad708c31d2f046c4ad52685ff213c56..a227136acc5fde6644f97584932cd7b312f05a7e 100644 (file)
@@ -3,7 +3,7 @@ import 'express-validator'
 import { values } from 'lodash'
 import 'multer'
 import * as validator from 'validator'
-import { UserRight, VideoRateType } from '../../../shared'
+import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared'
 import {
   CONSTRAINTS_FIELDS,
   VIDEO_CATEGORIES,
@@ -98,10 +98,18 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } |
   return isFileValid(files, videoImageTypesRegex, field, true)
 }
 
-function isVideoPrivacyValid (value: string) {
+function isVideoPrivacyValid (value: number) {
   return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined
 }
 
+function isScheduleVideoUpdatePrivacyValid (value: number) {
+  return validator.isInt(value + '') &&
+    (
+      value === VideoPrivacy.UNLISTED ||
+      value === VideoPrivacy.PUBLIC
+    )
+}
+
 function isVideoFileInfoHashValid (value: string) {
   return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
 }
@@ -174,6 +182,7 @@ export {
   isVideoFileInfoHashValid,
   isVideoNameValid,
   isVideoTagsValid,
+  isScheduleVideoUpdatePrivacyValid,
   isVideoAbuseReasonValid,
   isVideoFile,
   isVideoStateValid,