PeerTube/server/helpers/customValidators.js

35 lines
895 B
JavaScript
Raw Normal View History

'use strict'
2016-03-16 16:29:27 -05:00
const validator = require('validator')
2016-03-16 16:29:27 -05:00
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) &&
2016-05-03 15:41:46 -05:00
validator.isURL(val.podUrl) &&
2016-05-13 13:42:11 -05:00
!isNaN(val.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)
}
// ---------------------------------------------------------------------------
2016-01-31 04:23:52 -06:00
module.exports = customValidators