Files
gridpilot.gg/core/media/domain/value-objects/AvatarId.ts
2025-12-23 16:16:12 +01:00

31 lines
643 B
TypeScript

import type { IValueObject } from '@core/shared/domain';
export interface AvatarIdProps {
value: string;
}
export class AvatarId implements IValueObject<AvatarIdProps> {
public readonly props: AvatarIdProps;
private constructor(value: string) {
this.props = { value };
}
static create(raw: string): AvatarId {
const value = raw?.trim();
if (!value) {
throw new Error('Avatar ID cannot be empty');
}
return new AvatarId(value);
}
toString(): string {
return this.props.value;
}
equals(other: IValueObject<AvatarIdProps>): boolean {
return this.props.value === other.props.value;
}
}