aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/misc.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 8a270b777..275482fa1 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -25,10 +25,22 @@ function isIdOrUUIDValid (value: string) {
25 return isIdValid(value) || isUUIDValid(value) 25 return isIdValid(value) || isUUIDValid(value)
26} 26}
27 27
28function isBooleanValid (value: string) { 28function isBooleanValid (value: any) {
29 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) 29 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
30} 30}
31 31
32function toIntOrNull (value: string) {
33 if (value === 'null') return null
34
35 return validator.toInt(value)
36}
37
38function toStringOrNull (value: string) {
39 if (value === 'null') return null
40
41 return value
42}
43
32function isFileValid ( 44function isFileValid (
33 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], 45 files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
34 mimeTypeRegex: string, 46 mimeTypeRegex: string,
@@ -61,6 +73,8 @@ export {
61 isUUIDValid, 73 isUUIDValid,
62 isIdOrUUIDValid, 74 isIdOrUUIDValid,
63 isDateValid, 75 isDateValid,
76 toStringOrNull,
64 isBooleanValid, 77 isBooleanValid,
78 toIntOrNull,
65 isFileValid 79 isFileValid
66} 80}