2016-02-07 05:23:23 -05:00
|
|
|
'use strict'
|
2015-12-04 10:13:32 -05:00
|
|
|
|
2016-03-16 17:29:27 -04:00
|
|
|
const validator = require('validator')
|
2015-12-04 10:13:32 -05:00
|
|
|
|
2016-03-16 17:29:27 -04:00
|
|
|
const customValidators = {
|
2016-02-07 05:23:23 -05:00
|
|
|
eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid,
|
|
|
|
eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid,
|
|
|
|
isArray: isArray
|
|
|
|
}
|
2015-12-04 10:13:32 -05:00
|
|
|
|
2016-02-07 05:23:23 -05:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
}
|
2015-12-04 10:13:32 -05:00
|
|
|
|
2016-02-07 05:23:23 -05:00
|
|
|
function eachIsRemoteVideosRemoveValid (values) {
|
|
|
|
return values.every(function (val) {
|
|
|
|
return validator.isLength(val.magnetUri, 10)
|
|
|
|
})
|
|
|
|
}
|
2015-12-04 10:13:32 -05:00
|
|
|
|
2016-02-07 05:23:23 -05:00
|
|
|
function isArray (value) {
|
|
|
|
return Array.isArray(value)
|
|
|
|
}
|
2015-12-04 10:13:32 -05:00
|
|
|
|
2016-02-07 05:23:23 -05:00
|
|
|
// ---------------------------------------------------------------------------
|
2016-01-31 05:23:52 -05:00
|
|
|
|
2016-02-07 05:23:23 -05:00
|
|
|
module.exports = customValidators
|