Server: set manually the post host of a remote video throught the
[oweals/peertube.git] / server / helpers / custom-validators / pods.js
1 'use strict'
2
3 const validator = require('express-validator').validator
4
5 const miscValidators = require('./misc')
6
7 const podsValidators = {
8   isEachUniqueHostValid
9 }
10
11 function isEachUniqueHostValid (hosts) {
12   return miscValidators.isArray(hosts) &&
13     hosts.length !== 0 &&
14     hosts.every(function (host) {
15       return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host)
16     })
17 }
18
19 // ---------------------------------------------------------------------------
20
21 module.exports = podsValidators