aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-validators/user-notifications.ts
blob: 4fb5d922d61413097155f2bb1196d1b4778e357c (plain) (tree)


















                                                                                                           
import { exists } from './misc'
import * as validator from 'validator'
import { UserNotificationType } from '../../../shared/models/users'
import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'

function isUserNotificationTypeValid (value: any) {
  return exists(value) && validator.isInt('' + value) && UserNotificationType[value] !== undefined
}

function isUserNotificationSettingValid (value: any) {
  return exists(value) &&
    validator.isInt('' + value) &&
    UserNotificationSettingValue[ value ] !== undefined
}

export {
  isUserNotificationSettingValid,
  isUserNotificationTypeValid
}