]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/pods.ts
Update client dependencies
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / pods.ts
CommitLineData
4d4e5cd4 1import * as validator from 'validator'
d57d6f26 2
69818c93 3import { isArray, exists } from './misc'
67bf9b96 4
69818c93
C
5function isHostValid (host: string) {
6 return exists(host) && validator.isURL(host) && host.split('://').length === 1
d57d6f26
C
7}
8
69818c93 9function isEachUniqueHostValid (hosts: string[]) {
65fcc311 10 return isArray(hosts) &&
49abbbbe 11 hosts.length !== 0 &&
075f16ca 12 hosts.every(host => {
67bf9b96 13 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
d57d6f26
C
14 })
15}
16
17// ---------------------------------------------------------------------------
18
65fcc311
C
19export {
20 isEachUniqueHostValid,
21 isHostValid
22}
69818c93
C
23
24declare global {
25 namespace ExpressValidator {
26 export interface Validator {
27 isEachUniqueHostValid
28 isHostValid
29 }
30 }
31}