From 69818c9394366b954b6ba3bd697bd9d2b09f2a16 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 10 Jun 2017 22:15:25 +0200 Subject: Type functions --- server/helpers/custom-validators/pods.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'server/helpers/custom-validators/pods.ts') 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 @@ import * as validator from 'validator' -import { isArray } from './misc' +import { isArray, exists } from './misc' -function isHostValid (host) { - return validator.isURL(host) && host.split('://').length === 1 +function isHostValid (host: string) { + return exists(host) && validator.isURL(host) && host.split('://').length === 1 } -function isEachUniqueHostValid (hosts) { +function isEachUniqueHostValid (hosts: string[]) { return isArray(hosts) && hosts.length !== 0 && hosts.every(function (host) { @@ -20,3 +20,12 @@ export { isEachUniqueHostValid, isHostValid } + +declare global { + namespace ExpressValidator { + export interface Validator { + isEachUniqueHostValid + isHostValid + } + } +} -- cgit v1.2.3