blob: 9b982369ee9129dc4d4014f8eacd471fc2231fe0 (
plain) (
tree)
|
|
'use strict'
const validator = require('validator')
const constants = require('../initializers/constants')
const customValidators = {
eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid,
eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid,
isArray: isArray
}
function eachIsRemoteVideosAddValid (values) {
return values.every(function (val) {
return validator.isLength(val.name, 1, 50) &&
validator.isLength(val.description, 1, 50) &&
validator.isLength(val.magnetUri, 10) &&
validator.isURL(val.podUrl) &&
!isNaN(val.duration) &&
val.duration >= 0 &&
val.duration < constants.MAXIMUM_VIDEO_DURATION &&
validator.isDate(val.createdDate)
})
}
function eachIsRemoteVideosRemoveValid (values) {
return values.every(function (val) {
return validator.isLength(val.magnetUri, 10)
})
}
function isArray (value) {
return Array.isArray(value)
}
// ---------------------------------------------------------------------------
module.exports = customValidators
|