diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-09 11:23:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-09 11:41:18 +0200 |
commit | 360329cc029c062bfb145c90f7bf1c007c39af81 (patch) | |
tree | a40fb8e31c0d40d65a83e9f0fbc12793230b5c0e /server/helpers/custom-validators/misc.ts | |
parent | bf696869538eaef27e5a8445035967c01f214501 (diff) | |
download | PeerTube-360329cc029c062bfb145c90f7bf1c007c39af81.tar.gz PeerTube-360329cc029c062bfb145c90f7bf1c007c39af81.tar.zst PeerTube-360329cc029c062bfb145c90f7bf1c007c39af81.zip |
Account/channel descriptions are not required anymore
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r-- | server/helpers/custom-validators/misc.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 8a270b777..275482fa1 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -25,10 +25,22 @@ function isIdOrUUIDValid (value: string) { | |||
25 | return isIdValid(value) || isUUIDValid(value) | 25 | return isIdValid(value) || isUUIDValid(value) |
26 | } | 26 | } |
27 | 27 | ||
28 | function isBooleanValid (value: string) { | 28 | function isBooleanValid (value: any) { |
29 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) | 29 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) |
30 | } | 30 | } |
31 | 31 | ||
32 | function toIntOrNull (value: string) { | ||
33 | if (value === 'null') return null | ||
34 | |||
35 | return validator.toInt(value) | ||
36 | } | ||
37 | |||
38 | function toStringOrNull (value: string) { | ||
39 | if (value === 'null') return null | ||
40 | |||
41 | return value | ||
42 | } | ||
43 | |||
32 | function isFileValid ( | 44 | function isFileValid ( |
33 | files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], | 45 | files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], |
34 | mimeTypeRegex: string, | 46 | mimeTypeRegex: string, |
@@ -61,6 +73,8 @@ export { | |||
61 | isUUIDValid, | 73 | isUUIDValid, |
62 | isIdOrUUIDValid, | 74 | isIdOrUUIDValid, |
63 | isDateValid, | 75 | isDateValid, |
76 | toStringOrNull, | ||
64 | isBooleanValid, | 77 | isBooleanValid, |
78 | toIntOrNull, | ||
65 | isFileValid | 79 | isFileValid |
66 | } | 80 | } |