3 const validator
= require('validator')
5 const constants
= require('../initializers/constants')
7 const customValidators
= {
8 eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid
,
9 eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid
,
13 function eachIsRemoteVideosAddValid (values
) {
14 return values
.every(function (val
) {
15 return validator
.isLength(val
.name
, 1, 50) &&
16 validator
.isLength(val
.description
, 1, 50) &&
17 validator
.isLength(val
.magnetUri
, 10) &&
18 validator
.isURL(val
.podUrl
) &&
19 !isNaN(val
.duration
) &&
21 val
.duration
< constants
.MAXIMUM_VIDEO_DURATION
&&
22 validator
.isLength(val
.author
, 1, constants
.MAXIMUM_AUTHOR_LENGTH
) &&
23 validator
.isBase64(val
.thumbnailBase64
) &&
24 validator
.isByteLength(val
.thumbnailBase64
, { min: 0, max: 20000 }) &&
25 validator
.isDate(val
.createdDate
)
29 function eachIsRemoteVideosRemoveValid (values
) {
30 return values
.every(function (val
) {
31 return validator
.isLength(val
.magnetUri
, 10)
35 function isArray (value
) {
36 return Array
.isArray(value
)
39 // ---------------------------------------------------------------------------
41 module
.exports
= customValidators