]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/customValidators.js
Introduce paginations in videos listing
[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) &&
3a8a8b51
C
16 validator.isURL(val.podUrl) &&
17 !isNaN(val.duration)
9f10b292
C
18 })
19}
0b697522 20
9f10b292
C
21function eachIsRemoteVideosRemoveValid (values) {
22 return values.every(function (val) {
23 return validator.isLength(val.magnetUri, 10)
24 })
25}
0b697522 26
9f10b292
C
27function isArray (value) {
28 return Array.isArray(value)
29}
0b697522 30
9f10b292 31// ---------------------------------------------------------------------------
c45f7f84 32
9f10b292 33module.exports = customValidators