]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/pods.ts
Fix client compilation
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / pods.ts
index e4c827feb11b6405d964afce9499bb108e4e6a13..ec9f26cc8444caab3671f06870f4fc31ea8ed488 100644 (file)
@@ -1,14 +1,12 @@
-import expressValidator = require('express-validator')
-// TODO: use .validator when express-validator typing will have validator field
-const validator = expressValidator['validator']
+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) {
@@ -22,3 +20,12 @@ export {
   isEachUniqueHostValid,
   isHostValid
 }
+
+declare global {
+  namespace ExpressValidator {
+    export interface Validator {
+      isEachUniqueHostValid
+      isHostValid
+    }
+  }
+}