aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/pods.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/helpers/custom-validators/pods.ts
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-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.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}