PeerTube/server/helpers/custom-validators/pods.ts

23 lines
522 B
TypeScript
Raw Normal View History

2017-06-05 14:53:49 -05:00
import * as validator from 'validator'
2017-05-15 15:22:03 -05:00
import { isArray } from './misc'
2016-12-28 08:49:23 -06:00
function isHostValid (host) {
return validator.isURL(host) && host.split('://').length === 1
}
function isEachUniqueHostValid (hosts) {
2017-05-15 15:22:03 -05:00
return isArray(hosts) &&
hosts.length !== 0 &&
hosts.every(function (host) {
2016-12-28 08:49:23 -06:00
return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
})
}
// ---------------------------------------------------------------------------
2017-05-15 15:22:03 -05:00
export {
isEachUniqueHostValid,
isHostValid
}