1
0
Fork 0
peertube/server/helpers/custom-validators/user-notifications.ts
2021-03-24 18:18:40 +01:00

23 lines
737 B
TypeScript

import validator from 'validator'
import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
import { exists } from './misc'
function isUserNotificationTypeValid (value: any) {
return exists(value) && validator.isInt('' + value)
}
function isUserNotificationSettingValid (value: any) {
return exists(value) &&
validator.isInt('' + value) &&
(
value === UserNotificationSettingValue.NONE ||
value === UserNotificationSettingValue.WEB ||
value === UserNotificationSettingValue.EMAIL ||
value === (UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL)
)
}
export {
isUserNotificationSettingValid,
isUserNotificationTypeValid
}