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 6d10a65a8..76647fea2 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -9,6 +9,14 @@ function isArray (value: any) {
9 return Array.isArray(value) 9 return Array.isArray(value)
10} 10}
11 11
12function isNotEmptyIntArray (value: any) {
13 return Array.isArray(value) && value.every(v => validator.isInt('' + v)) && value.length !== 0
14}
15
16function isArrayOf (value: any, validator: (value: any) => boolean) {
17 return isArray(value) && value.every(v => validator(v))
18}
19
12function isDateValid (value: string) { 20function isDateValid (value: string) {
13 return exists(value) && validator.isISO8601(value) 21 return exists(value) && validator.isISO8601(value)
14} 22}
@@ -78,6 +86,8 @@ function isFileValid (
78 86
79export { 87export {
80 exists, 88 exists,
89 isArrayOf,
90 isNotEmptyIntArray,
81 isArray, 91 isArray,
82 isIdValid, 92 isIdValid,
83 isUUIDValid, 93 isUUIDValid,