]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - helpers/customValidators.js
Infile code reorganization
[github/Chocobozzz/PeerTube.git] / helpers / customValidators.js
CommitLineData
0b697522
C
1;(function () {
2 'use strict'
3
4 var validator = require('validator')
5
c45f7f84
C
6 var customValidators = {
7 eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid,
8 eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid,
9 isArray: isArray
10 }
0b697522 11
c45f7f84 12 function eachIsRemoteVideosAddValid (values) {
0b697522
C
13 return values.every(function (val) {
14 return validator.isLength(val.name, 1, 50) &&
15 validator.isLength(val.description, 1, 50) &&
16 validator.isLength(val.magnetUri, 10) &&
17 validator.isURL(val.podUrl)
18 })
19 }
20
c45f7f84 21 function eachIsRemoteVideosRemoveValid (values) {
0b697522
C
22 return values.every(function (val) {
23 return validator.isLength(val.magnetUri, 10)
24 })
25 }
26
c45f7f84 27 function isArray (value) {
0b697522
C
28 return Array.isArray(value)
29 }
30
c45f7f84
C
31 // ---------------------------------------------------------------------------
32
0b697522
C
33 module.exports = customValidators
34})()