]>
Commit | Line | Data |
---|---|---|
1 | ;(function () { | |
2 | 'use strict' | |
3 | ||
4 | var validator = require('validator') | |
5 | ||
6 | var customValidators = { | |
7 | eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid, | |
8 | eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid, | |
9 | isArray: isArray | |
10 | } | |
11 | ||
12 | function eachIsRemoteVideosAddValid (values) { | |
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 | ||
21 | function eachIsRemoteVideosRemoveValid (values) { | |
22 | return values.every(function (val) { | |
23 | return validator.isLength(val.magnetUri, 10) | |
24 | }) | |
25 | } | |
26 | ||
27 | function isArray (value) { | |
28 | return Array.isArray(value) | |
29 | } | |
30 | ||
31 | // --------------------------------------------------------------------------- | |
32 | ||
33 | module.exports = customValidators | |
34 | })() |