2020-01-07 07:56:07 -06:00
|
|
|
import validator from 'validator'
|
2018-12-26 03:36:24 -06:00
|
|
|
import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
|
2021-03-11 03:55:09 -06:00
|
|
|
import { exists } from './misc'
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
function isUserNotificationTypeValid (value: any) {
|
2021-03-11 03:55:09 -06:00
|
|
|
return exists(value) && validator.isInt('' + value)
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function isUserNotificationSettingValid (value: any) {
|
|
|
|
return exists(value) &&
|
2020-01-31 09:56:52 -06:00
|
|
|
validator.isInt('' + value) &&
|
|
|
|
(
|
2019-01-08 04:26:41 -06:00
|
|
|
value === UserNotificationSettingValue.NONE ||
|
|
|
|
value === UserNotificationSettingValue.WEB ||
|
|
|
|
value === UserNotificationSettingValue.EMAIL ||
|
|
|
|
value === (UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL)
|
|
|
|
)
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
isUserNotificationSettingValid,
|
|
|
|
isUserNotificationTypeValid
|
|
|
|
}
|