]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/videos.ts
Misc cleanup
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / videos.ts
index c893d2c7cf54c8b88f6f831380222e4cf71783df..205d8c62f56e68fa44000199a362df325f2c5c86 100644 (file)
@@ -90,12 +90,20 @@ function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } |
   return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype)
 }
 
+function isVideoPrivacyValid (value: string) {
+  return VIDEO_PRIVACIES[value] !== undefined
+}
+
 function isVideoFileInfoHashValid (value: string) {
   return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
 }
 
-function isVideoPrivacyValid (value: string) {
-  return VIDEO_PRIVACIES[value] !== undefined
+function isVideoFileResolutionValid (value: string) {
+  return exists(value) && validator.isInt(value + '')
+}
+
+function isVideoFileSizeValid (value: string) {
+  return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE)
 }
 
 function checkVideoExists (id: string, res: Response, callback: () => void) {
@@ -142,5 +150,7 @@ export {
   isVideoTagValid,
   isVideoUrlValid,
   isVideoPrivacyValid,
+  isVideoFileResolutionValid,
+  isVideoFileSizeValid,
   checkVideoExists
 }