mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Server: add database field validations
This commit is contained in:
parent
552cc9d646
commit
67bf9b96bb
13 changed files with 162 additions and 73 deletions
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ const videosValidators = {
|
|||
isVideoDurationValid,
|
||||
isVideoInfoHashValid,
|
||||
isVideoNameValid,
|
||||
isVideoPodHostValid,
|
||||
isVideoTagsValid,
|
||||
isVideoThumbnailValid,
|
||||
isVideoThumbnail64Valid
|
||||
|
@ -74,11 +73,6 @@ function isVideoNameValid (value) {
|
|||
return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME)
|
||||
}
|
||||
|
||||
function isVideoPodHostValid (value) {
|
||||
// TODO: set options (TLD...)
|
||||
return validator.isURL(value)
|
||||
}
|
||||
|
||||
function isVideoTagsValid (tags) {
|
||||
return miscValidators.isArray(tags) &&
|
||||
validator.isInt(tags.length, VIDEOS_CONSTRAINTS_FIELDS.TAGS) &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue