diff options
Diffstat (limited to 'server/helpers/custom-validators/pods.ts')
-rw-r--r-- | server/helpers/custom-validators/pods.ts | 17 |
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 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | 2 | ||
3 | import { isArray } from './misc' | 3 | import { isArray, exists } from './misc' |
4 | 4 | ||
5 | function isHostValid (host) { | 5 | function 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 | ||
9 | function isEachUniqueHostValid (hosts) { | 9 | function 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 | |||
24 | declare global { | ||
25 | namespace ExpressValidator { | ||
26 | export interface Validator { | ||
27 | isEachUniqueHostValid | ||
28 | isHostValid | ||
29 | } | ||
30 | } | ||
31 | } | ||