aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-07-25 22:01:25 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-07-25 22:01:25 +0200
commitc1e791bad0b079af67398f6407221e6dcbb573dd (patch)
tree82e5944b4458dd35aa482a38f6b650eb93bb89ad /server/helpers/custom-validators/misc.ts
parent5f7021c33d31c5255b995ae0ff86b5bbea4ea4b9 (diff)
downloadPeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.gz
PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.zst
PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.zip
expliciting type checks and predicates (server only)
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r--server/helpers/custom-validators/misc.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 151fc852b..6d10a65a8 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -51,7 +51,7 @@ function isFileValid (
51 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], 51 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
52 mimeTypeRegex: string, 52 mimeTypeRegex: string,
53 field: string, 53 field: string,
54 maxSize: number, 54 maxSize: number | null,
55 optional = false 55 optional = false
56) { 56) {
57 // Should have files 57 // Should have files
@@ -69,7 +69,7 @@ function isFileValid (
69 if (!file || !file.originalname) return false 69 if (!file || !file.originalname) return false
70 70
71 // Check size 71 // Check size
72 if (maxSize && file.size > maxSize) return false 72 if ((maxSize !== null) && file.size > maxSize) return false
73 73
74 return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype) 74 return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype)
75} 75}