From 2b65c4e53511ccb85b17479cb1c62717afb8511c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 25 Jul 2019 17:28:45 +0200 Subject: Fix scheduled privacy and verify email validations --- server/helpers/custom-validators/misc.ts | 5 ++--- server/helpers/custom-validators/videos.ts | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'server/helpers') 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 @@ import 'multer' import * as validator from 'validator' import { sep } from 'path' -import toBoolean = require('validator/lib/toBoolean') function exists (value: any) { return value !== undefined && value !== null @@ -52,7 +51,7 @@ function toIntOrNull (value: string) { if (v === null || v === undefined) return v if (typeof v === 'number') return v - return validator.toInt(v) + return validator.toInt('' + v) } function toBooleanOrNull (value: any) { @@ -61,7 +60,7 @@ function toBooleanOrNull (value: any) { if (v === null || v === undefined) return v if (typeof v === 'boolean') return v - return toBoolean(v) + return validator.toBoolean('' + v) } function 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[] } | } function isVideoPrivacyValid (value: number) { - return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined + return VIDEO_PRIVACIES[ value ] !== undefined } function isScheduleVideoUpdatePrivacyValid (value: number) { - return validator.isInt(value + '') && - ( - value === VideoPrivacy.UNLISTED || - value === VideoPrivacy.PUBLIC - ) + return value === VideoPrivacy.UNLISTED || value === VideoPrivacy.PUBLIC } function isVideoOriginallyPublishedAtValid (value: string | null) { -- cgit v1.2.3