22 lines
446 B
TypeScript
22 lines
446 B
TypeScript
export class UserId {
|
|
private readonly value: string;
|
|
|
|
private constructor(value: string) {
|
|
if (!value || !value.trim()) {
|
|
throw new Error('UserId cannot be empty');
|
|
}
|
|
this.value = value;
|
|
}
|
|
|
|
public static fromString(value: string): UserId {
|
|
return new UserId(value);
|
|
}
|
|
|
|
public toString(): string {
|
|
return this.value;
|
|
}
|
|
|
|
public equals(other: UserId): boolean {
|
|
return this.value === other.value;
|
|
}
|
|
} |