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