fix issues in core
This commit is contained in:
31
core/media/domain/value-objects/AvatarId.ts
Normal file
31
core/media/domain/value-objects/AvatarId.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user