wip
This commit is contained in:
@@ -1,22 +1,32 @@
|
||||
export class UserId {
|
||||
private readonly value: string;
|
||||
import type { IValueObject } from '@gridpilot/shared/domain';
|
||||
|
||||
export interface UserIdProps {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export class UserId implements IValueObject<UserIdProps> {
|
||||
public readonly props: UserIdProps;
|
||||
|
||||
private constructor(value: string) {
|
||||
if (!value || !value.trim()) {
|
||||
throw new Error('UserId cannot be empty');
|
||||
}
|
||||
this.value = value;
|
||||
this.props = { value };
|
||||
}
|
||||
|
||||
public static fromString(value: string): UserId {
|
||||
return new UserId(value);
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
return this.value;
|
||||
get value(): string {
|
||||
return this.props.value;
|
||||
}
|
||||
|
||||
public equals(other: UserId): boolean {
|
||||
return this.value === other.value;
|
||||
public toString(): string {
|
||||
return this.props.value;
|
||||
}
|
||||
|
||||
public equals(other: IValueObject<UserIdProps>): boolean {
|
||||
return this.props.value === other.props.value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user