Files
ulitka/src/modules/notification/domain/value-objects/notification-channel.vo.ts
T
2026-09-29 18:42:29 +03:00

24 lines
792 B
TypeScript

export const NOTIFICATION_CHANNELS = ['EMAIL', 'PUSH'] as const;
export type NotificationChannelValue = (typeof NOTIFICATION_CHANNELS)[number];
export class NotificationChannel {
private constructor(private readonly _value: NotificationChannelValue) {}
static create(value: string): NotificationChannel {
if (!NOTIFICATION_CHANNELS.includes(value as NotificationChannelValue)) {
throw new Error(`Недопустимый канал уведомлений: "${value}". Разрешены: ${NOTIFICATION_CHANNELS.join(', ')}`);
}
return new NotificationChannel(value as NotificationChannelValue);
}
get value(): NotificationChannelValue {
return this._value;
}
equals(other: NotificationChannel): boolean {
return this._value === other.value;
}
}