aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-validators/pods.js
blob: 0154a242432b1bf43b6bc35ab94bb105864f82e8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                                                        
                       

 




                                                                                                                       





                                                                              
'use strict'

const validator = require('express-validator').validator

const miscValidators = require('./misc')

const podsValidators = {
  isEachUniqueHostValid
}

function isEachUniqueHostValid (hosts) {
  return miscValidators.isArray(hosts) &&
    hosts.length !== 0 &&
    hosts.every(function (host) {
      return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host)
    })
}

// ---------------------------------------------------------------------------

module.exports = podsValidators