diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-12-04 16:13:32 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-12-04 16:13:32 +0100 |
commit | 0b69752270f1ceea06a29872b3db23660a55d6d3 (patch) | |
tree | 42da726633f3e48f4fe592cfd2c1ca14346a159b /src/customValidators.js | |
parent | af82cae07dc568e3cb10acd70113df56eb8b15a9 (diff) | |
download | PeerTube-0b69752270f1ceea06a29872b3db23660a55d6d3.tar.gz PeerTube-0b69752270f1ceea06a29872b3db23660a55d6d3.tar.zst PeerTube-0b69752270f1ceea06a29872b3db23660a55d6d3.zip |
Add a pool of requests instead of making a request at each action (add
video/remove video) for performance in big networks
Diffstat (limited to 'src/customValidators.js')
-rw-r--r-- | src/customValidators.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/customValidators.js b/src/customValidators.js new file mode 100644 index 000000000..73c2f8461 --- /dev/null +++ b/src/customValidators.js | |||
@@ -0,0 +1,29 @@ | |||
1 | ;(function () { | ||
2 | 'use strict' | ||
3 | |||
4 | var validator = require('validator') | ||
5 | |||
6 | var customValidators = {} | ||
7 | |||
8 | customValidators.eachIsRemoteVideosAddValid = function (values) { | ||
9 | return values.every(function (val) { | ||
10 | return validator.isLength(val.name, 1, 50) && | ||
11 | validator.isLength(val.description, 1, 50) && | ||
12 | validator.isLength(val.magnetUri, 10) && | ||
13 | validator.isURL(val.podUrl) | ||
14 | }) | ||
15 | } | ||
16 | |||
17 | customValidators.eachIsRemoteVideosRemoveValid = function (values) { | ||
18 | return values.every(function (val) { | ||
19 | return validator.isLength(val.magnetUri, 10) | ||
20 | }) | ||
21 | } | ||
22 | |||
23 | customValidators.isArray = function (value) { | ||
24 | return Array.isArray(value) | ||
25 | } | ||
26 | |||
27 | // ----------- Export ----------- | ||
28 | module.exports = customValidators | ||
29 | })() | ||