import type { ValueObject } from '@core/shared/domain/ValueObject'; import { v4 as uuidv4 } from 'uuid'; export interface UserIdProps { value: string; } export class UserId implements ValueObject { public readonly props: UserIdProps; private constructor(value: string) { if (!value || !value.trim()) { throw new Error('UserId cannot be empty'); } this.props = { value }; } public static create(): UserId { return new UserId(uuidv4()); } public static fromString(value: string): UserId { return new UserId(value); } get value(): string { return this.props.value; } public toString(): string { return this.props.value; } public equals(other: ValueObject): boolean { return this.props.value === other.props.value; } }