diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
commit | 69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch) | |
tree | ad199a18ec3c322460d6f9523fc383ee562554e0 /server/helpers/custom-validators/pods.ts | |
parent | 4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff) | |
download | PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip |
Type functions
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 | } | ||