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.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 528bfcfb8..f8f168149 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -39,6 +39,10 @@ function isUUIDValid (value: string) {
39 return exists(value) && validator.isUUID('' + value, 4) 39 return exists(value) && validator.isUUID('' + value, 4)
40} 40}
41 41
42function areUUIDsValid (values: string[]) {
43 return isArray(values) && values.every(v => isUUIDValid(v))
44}
45
42function isIdOrUUIDValid (value: string) { 46function isIdOrUUIDValid (value: string) {
43 return isIdValid(value) || isUUIDValid(value) 47 return isIdValid(value) || isUUIDValid(value)
44} 48}
@@ -132,6 +136,10 @@ function toCompleteUUID (value: string) {
132 return value 136 return value
133} 137}
134 138
139function toCompleteUUIDs (values: string[]) {
140 return values.map(v => toCompleteUUID(v))
141}
142
135function toIntOrNull (value: string) { 143function toIntOrNull (value: string) {
136 const v = toValueOrNull(value) 144 const v = toValueOrNull(value)
137 145
@@ -180,6 +188,7 @@ export {
180 isIdValid, 188 isIdValid,
181 isSafePath, 189 isSafePath,
182 isUUIDValid, 190 isUUIDValid,
191 toCompleteUUIDs,
183 toCompleteUUID, 192 toCompleteUUID,
184 isIdOrUUIDValid, 193 isIdOrUUIDValid,
185 isDateValid, 194 isDateValid,
@@ -187,6 +196,7 @@ export {
187 toBooleanOrNull, 196 toBooleanOrNull,
188 isBooleanValid, 197 isBooleanValid,
189 toIntOrNull, 198 toIntOrNull,
199 areUUIDsValid,
190 toArray, 200 toArray,
191 toIntArray, 201 toIntArray,
192 isFileFieldValid, 202 isFileFieldValid,