+function toIntOrNull (value: string) {
+ if (value === 'null') return null
+
+ return validator.toInt(value)
+}
+
+function toStringOrNull (value: string) {
+ if (value === 'null') return null
+
+ return value
+}
+
+function isFileValid (
+ 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)
+}
+