+function toIntArray (value: any) {
+ if (!value) return []
+ if (isArray(value) === false) return [ validator.toInt(value) ]
+
+ return value.map(v => validator.toInt(v))
+}
+
+function isFileFieldValid (
+ files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
+ field: string,
+ optional = false
+) {
+ // Should have files
+ if (!files) return optional
+ if (isArray(files)) return optional
+
+ // Should have a file
+ const fileArray = files[field]
+ if (!fileArray || fileArray.length === 0) {
+ return optional
+ }
+
+ // The file should exist
+ const file = fileArray[0]
+ if (!file || !file.originalname) return false
+ return file
+}
+
+function isFileMimeTypeValid (
+ files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
+ mimeTypeRegex: string,
+ field: string,
+ optional = false
+) {
+ // Should have files
+ if (!files) return optional
+ if (isArray(files)) return optional
+
+ // Should have a file
+ const fileArray = files[field]
+ if (!fileArray || fileArray.length === 0) {
+ return optional
+ }
+
+ // The file should exist
+ const file = fileArray[0]
+ if (!file || !file.originalname) return false
+
+ return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype)
+}
+