diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/misc.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 76647fea2..3a3deab0c 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -49,12 +49,19 @@ function toValueOrNull (value: string) { | |||
49 | return value | 49 | return value |
50 | } | 50 | } |
51 | 51 | ||
52 | function toArray (value: string) { | 52 | function toArray (value: any) { |
53 | if (value && isArray(value) === false) return [ value ] | 53 | if (value && isArray(value) === false) return [ value ] |
54 | 54 | ||
55 | return value | 55 | return value |
56 | } | 56 | } |
57 | 57 | ||
58 | function toIntArray (value: any) { | ||
59 | if (!value) return [] | ||
60 | if (isArray(value) === false) return [ validator.toInt(value) ] | ||
61 | |||
62 | return value.map(v => validator.toInt(v)) | ||
63 | } | ||
64 | |||
58 | function isFileValid ( | 65 | function isFileValid ( |
59 | files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], | 66 | files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], |
60 | mimeTypeRegex: string, | 67 | mimeTypeRegex: string, |
@@ -97,5 +104,6 @@ export { | |||
97 | isBooleanValid, | 104 | isBooleanValid, |
98 | toIntOrNull, | 105 | toIntOrNull, |
99 | toArray, | 106 | toArray, |
107 | toIntArray, | ||
100 | isFileValid | 108 | isFileValid |
101 | } | 109 | } |