aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/pods.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/pods.ts')
-rw-r--r--server/helpers/custom-validators/pods.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts
index ee939ad04..ec9f26cc8 100644
--- a/server/helpers/custom-validators/pods.ts
+++ b/server/helpers/custom-validators/pods.ts
@@ -1,12 +1,12 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2 2
3import { isArray } from './misc' 3import { isArray, exists } from './misc'
4 4
5function isHostValid (host) { 5function isHostValid (host: string) {
6 return validator.isURL(host) && host.split('://').length === 1 6 return exists(host) && validator.isURL(host) && host.split('://').length === 1
7} 7}
8 8
9function isEachUniqueHostValid (hosts) { 9function isEachUniqueHostValid (hosts: string[]) {
10 return isArray(hosts) && 10 return isArray(hosts) &&
11 hosts.length !== 0 && 11 hosts.length !== 0 &&
12 hosts.every(function (host) { 12 hosts.every(function (host) {
@@ -20,3 +20,12 @@ export {
20 isEachUniqueHostValid, 20 isEachUniqueHostValid,
21 isHostValid 21 isHostValid
22} 22}
23
24declare global {
25 namespace ExpressValidator {
26 export interface Validator {
27 isEachUniqueHostValid
28 isHostValid
29 }
30 }
31}