mirror of https://github.com/Chocobozzz/PeerTube
24 lines
691 B
TypeScript
24 lines
691 B
TypeScript
import validator from 'validator'
|
|
import { UserNotificationSettingValue } from '@shared/models'
|
|
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
|
|
}
|