Files
gridpilot.gg/core/media/domain/value-objects/AvatarId.ts
2026-01-16 16:46:57 +01:00

31 lines
652 B
TypeScript

import type { ValueObject } from '@core/shared/domain/ValueObject';
export interface AvatarIdProps {
value: string;
}
export class AvatarId implements ValueObject<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: ValueObject<AvatarIdProps>): boolean {
return this.props.value === other.props.value;
}
}