diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-24 19:41:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-26 09:11:38 +0200 |
commit | 72c7248b6fdcdb2175e726ff51b42e7555f2bd84 (patch) | |
tree | 1bfdee99dbe2392cc997edba8e314e2a8a401c72 /server/helpers/custom-validators/misc.ts | |
parent | 8113a93a0d9f31aa9e23702bbc31b8a76275ae22 (diff) | |
download | PeerTube-72c7248b6fdcdb2175e726ff51b42e7555f2bd84.tar.gz PeerTube-72c7248b6fdcdb2175e726ff51b42e7555f2bd84.tar.zst PeerTube-72c7248b6fdcdb2175e726ff51b42e7555f2bd84.zip |
Add video channels
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r-- | server/helpers/custom-validators/misc.ts | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 60fcdd5bb..160ec91f3 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import 'express-validator' | 1 | import * as validator from 'validator' |
2 | 2 | ||
3 | function exists (value: any) { | 3 | function exists (value: any) { |
4 | return value !== undefined && value !== null | 4 | return value !== undefined && value !== null |
@@ -8,9 +8,29 @@ function isArray (value: any) { | |||
8 | return Array.isArray(value) | 8 | return Array.isArray(value) |
9 | } | 9 | } |
10 | 10 | ||
11 | function isDateValid (value: string) { | ||
12 | return exists(value) && validator.isISO8601(value) | ||
13 | } | ||
14 | |||
15 | function isIdValid (value: string) { | ||
16 | return exists(value) && validator.isInt('' + value) | ||
17 | } | ||
18 | |||
19 | function isUUIDValid (value: string) { | ||
20 | return exists(value) && validator.isUUID('' + value, 4) | ||
21 | } | ||
22 | |||
23 | function isIdOrUUIDValid (value: string) { | ||
24 | return isIdValid(value) || isUUIDValid(value) | ||
25 | } | ||
26 | |||
11 | // --------------------------------------------------------------------------- | 27 | // --------------------------------------------------------------------------- |
12 | 28 | ||
13 | export { | 29 | export { |
14 | exists, | 30 | exists, |
15 | isArray | 31 | isArray, |
32 | isIdValid, | ||
33 | isUUIDValid, | ||
34 | isIdOrUUIDValid, | ||
35 | isDateValid | ||
16 | } | 36 | } |