aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/misc.ts5
-rw-r--r--server/helpers/custom-validators/videos.ts8
2 files changed, 4 insertions, 9 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 1b7e00431..0c3df1cd0 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -1,7 +1,6 @@
1import 'multer' 1import 'multer'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import { sep } from 'path' 3import { sep } from 'path'
4import toBoolean = require('validator/lib/toBoolean')
5 4
6function exists (value: any) { 5function exists (value: any) {
7 return value !== undefined && value !== null 6 return value !== undefined && value !== null
@@ -52,7 +51,7 @@ function toIntOrNull (value: string) {
52 if (v === null || v === undefined) return v 51 if (v === null || v === undefined) return v
53 if (typeof v === 'number') return v 52 if (typeof v === 'number') return v
54 53
55 return validator.toInt(v) 54 return validator.toInt('' + v)
56} 55}
57 56
58function toBooleanOrNull (value: any) { 57function toBooleanOrNull (value: any) {
@@ -61,7 +60,7 @@ function toBooleanOrNull (value: any) {
61 if (v === null || v === undefined) return v 60 if (v === null || v === undefined) return v
62 if (typeof v === 'boolean') return v 61 if (typeof v === 'boolean') return v
63 62
64 return toBoolean(v) 63 return validator.toBoolean('' + v)
65} 64}
66 65
67function toValueOrNull (value: string) { 66function toValueOrNull (value: string) {
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 9ab1ef234..e92ef9b92 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -98,15 +98,11 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } |
98} 98}
99 99
100function isVideoPrivacyValid (value: number) { 100function isVideoPrivacyValid (value: number) {
101 return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined 101 return VIDEO_PRIVACIES[ value ] !== undefined
102} 102}
103 103
104function isScheduleVideoUpdatePrivacyValid (value: number) { 104function isScheduleVideoUpdatePrivacyValid (value: number) {
105 return validator.isInt(value + '') && 105 return value === VideoPrivacy.UNLISTED || value === VideoPrivacy.PUBLIC
106 (
107 value === VideoPrivacy.UNLISTED ||
108 value === VideoPrivacy.PUBLIC
109 )
110} 106}
111 107
112function isVideoOriginallyPublishedAtValid (value: string | null) { 108function isVideoOriginallyPublishedAtValid (value: string | null) {