aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-28 16:40:21 +0200
committerChocobozzz <me@florianbigard.com>2021-07-28 16:40:21 +0200
commitfbd67e7f386504e50f2504cb6386700a58906f16 (patch)
tree1a7143aaea76ce4e195fb9d6214a0cd769c556ea /server/helpers/custom-validators/misc.ts
parent164c8d46cf5c948a28b4ac0e596fad9b83b2c229 (diff)
downloadPeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.tar.gz
PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.tar.zst
PeerTube-fbd67e7f386504e50f2504cb6386700a58906f16.zip
Add ability to search by uuids/actor names
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,