1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Server: add database field validations

This commit is contained in:
Chocobozzz 2016-12-28 15:49:23 +01:00
parent 552cc9d646
commit 67bf9b96bb
13 changed files with 162 additions and 73 deletions

View file

@ -5,14 +5,19 @@ const validator = require('express-validator').validator
const miscValidators = require('./misc')
const podsValidators = {
isEachUniqueHostValid
isEachUniqueHostValid,
isHostValid
}
function isHostValid (host) {
return validator.isURL(host) && host.split('://').length === 1
}
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)
return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
})
}