diff options
Diffstat (limited to 'server/helpers/custom-validators/user-notifications.ts')
-rw-r--r-- | server/helpers/custom-validators/user-notifications.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/user-notifications.ts b/server/helpers/custom-validators/user-notifications.ts new file mode 100644 index 000000000..4fb5d922d --- /dev/null +++ b/server/helpers/custom-validators/user-notifications.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { exists } from './misc' | ||
2 | import * as validator from 'validator' | ||
3 | import { UserNotificationType } from '../../../shared/models/users' | ||
4 | import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' | ||
5 | |||
6 | function isUserNotificationTypeValid (value: any) { | ||
7 | return exists(value) && validator.isInt('' + value) && UserNotificationType[value] !== undefined | ||
8 | } | ||
9 | |||
10 | function isUserNotificationSettingValid (value: any) { | ||
11 | return exists(value) && | ||
12 | validator.isInt('' + value) && | ||
13 | UserNotificationSettingValue[ value ] !== undefined | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | isUserNotificationSettingValid, | ||
18 | isUserNotificationTypeValid | ||
19 | } | ||