From 2f1548fda32c3ba9e53913270394eedfacd55986 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Jan 2019 11:26:41 +0100 Subject: Add notifications in the client --- server/helpers/custom-validators/misc.ts | 6 +++--- server/helpers/custom-validators/user-notifications.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index a093e3e1b..b6f0ebe6f 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -9,8 +9,8 @@ function isArray (value: any) { return Array.isArray(value) } -function isIntArray (value: any) { - return Array.isArray(value) && value.every(v => validator.isInt('' + v)) +function isNotEmptyIntArray (value: any) { + return Array.isArray(value) && value.every(v => validator.isInt('' + v)) && value.length !== 0 } function isDateValid (value: string) { @@ -82,7 +82,7 @@ function isFileValid ( export { exists, - isIntArray, + isNotEmptyIntArray, isArray, isIdValid, isUUIDValid, diff --git a/server/helpers/custom-validators/user-notifications.ts b/server/helpers/custom-validators/user-notifications.ts index 4fb5d922d..02ea3bbc2 100644 --- a/server/helpers/custom-validators/user-notifications.ts +++ b/server/helpers/custom-validators/user-notifications.ts @@ -9,8 +9,12 @@ function isUserNotificationTypeValid (value: any) { function isUserNotificationSettingValid (value: any) { return exists(value) && - validator.isInt('' + value) && - UserNotificationSettingValue[ value ] !== undefined + validator.isInt('' + value) && ( + value === UserNotificationSettingValue.NONE || + value === UserNotificationSettingValue.WEB || + value === UserNotificationSettingValue.EMAIL || + value === (UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL) + ) } export { -- cgit v1.2.3