diff options
Diffstat (limited to 'helpers/customValidators.js')
-rw-r--r-- | helpers/customValidators.js | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/helpers/customValidators.js b/helpers/customValidators.js index c433e5c5d..20c41f5da 100644 --- a/helpers/customValidators.js +++ b/helpers/customValidators.js | |||
@@ -1,34 +1,32 @@ | |||
1 | ;(function () { | 1 | 'use strict' |
2 | 'use strict' | ||
3 | 2 | ||
4 | var validator = require('validator') | 3 | var validator = require('validator') |
5 | 4 | ||
6 | var customValidators = { | 5 | var customValidators = { |
7 | eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid, | 6 | eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid, |
8 | eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid, | 7 | eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid, |
9 | isArray: isArray | 8 | isArray: isArray |
10 | } | 9 | } |
11 | 10 | ||
12 | function eachIsRemoteVideosAddValid (values) { | 11 | function eachIsRemoteVideosAddValid (values) { |
13 | return values.every(function (val) { | 12 | return values.every(function (val) { |
14 | return validator.isLength(val.name, 1, 50) && | 13 | return validator.isLength(val.name, 1, 50) && |
15 | validator.isLength(val.description, 1, 50) && | 14 | validator.isLength(val.description, 1, 50) && |
16 | validator.isLength(val.magnetUri, 10) && | 15 | validator.isLength(val.magnetUri, 10) && |
17 | validator.isURL(val.podUrl) | 16 | validator.isURL(val.podUrl) |
18 | }) | 17 | }) |
19 | } | 18 | } |
20 | 19 | ||
21 | function eachIsRemoteVideosRemoveValid (values) { | 20 | function eachIsRemoteVideosRemoveValid (values) { |
22 | return values.every(function (val) { | 21 | return values.every(function (val) { |
23 | return validator.isLength(val.magnetUri, 10) | 22 | return validator.isLength(val.magnetUri, 10) |
24 | }) | 23 | }) |
25 | } | 24 | } |
26 | 25 | ||
27 | function isArray (value) { | 26 | function isArray (value) { |
28 | return Array.isArray(value) | 27 | return Array.isArray(value) |
29 | } | 28 | } |
30 | 29 | ||
31 | // --------------------------------------------------------------------------- | 30 | // --------------------------------------------------------------------------- |
32 | 31 | ||
33 | module.exports = customValidators | 32 | module.exports = customValidators |
34 | })() | ||