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