aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r--server/helpers/custom-validators/misc.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 254b4db6c..455aae367 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -45,6 +45,7 @@ function isFileValid (
45 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], 45 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
46 mimeTypeRegex: string, 46 mimeTypeRegex: string,
47 field: string, 47 field: string,
48 maxSize: number,
48 optional = false 49 optional = false
49) { 50) {
50 // Should have files 51 // Should have files
@@ -61,6 +62,9 @@ function isFileValid (
61 const file = fileArray[ 0 ] 62 const file = fileArray[ 0 ]
62 if (!file || !file.originalname) return false 63 if (!file || !file.originalname) return false
63 64
65 // Check size
66 if (maxSize && file.size > maxSize) return false
67
64 return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype) 68 return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype)
65} 69}
66 70