aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/pods.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-28 15:49:23 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-28 15:49:23 +0100
commit67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677 (patch)
treebae6a9b0c3133c9cc38a2972222b5991f0cf614e /server/helpers/custom-validators/pods.js
parent552cc9d646e78edae8b0fe61564d4e49db0b6206 (diff)
downloadPeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.tar.gz
PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.tar.zst
PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.zip
Server: add database field validations
Diffstat (limited to 'server/helpers/custom-validators/pods.js')
-rw-r--r--server/helpers/custom-validators/pods.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/pods.js b/server/helpers/custom-validators/pods.js
index 0154a2424..8bb3733ff 100644
--- a/server/helpers/custom-validators/pods.js
+++ b/server/helpers/custom-validators/pods.js
@@ -5,14 +5,19 @@ const validator = require('express-validator').validator
5const miscValidators = require('./misc') 5const miscValidators = require('./misc')
6 6
7const podsValidators = { 7const podsValidators = {
8 isEachUniqueHostValid 8 isEachUniqueHostValid,
9 isHostValid
10}
11
12function isHostValid (host) {
13 return validator.isURL(host) && host.split('://').length === 1
9} 14}
10 15
11function isEachUniqueHostValid (hosts) { 16function isEachUniqueHostValid (hosts) {
12 return miscValidators.isArray(hosts) && 17 return miscValidators.isArray(hosts) &&
13 hosts.length !== 0 && 18 hosts.length !== 0 &&
14 hosts.every(function (host) { 19 hosts.every(function (host) {
15 return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host) 20 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
16 }) 21 })
17} 22}
18 23