37 lines
889 B
TypeScript
37 lines
889 B
TypeScript
import type { IValueObject } from '@gridpilot/shared/domain';
|
|
|
|
export interface AnalyticsEntityIdProps {
|
|
value: string;
|
|
}
|
|
|
|
/**
|
|
* Value Object: AnalyticsEntityId
|
|
*
|
|
* Represents the ID of an entity (league, driver, team, race, sponsor)
|
|
* within the analytics bounded context.
|
|
*/
|
|
export class AnalyticsEntityId implements IValueObject<AnalyticsEntityIdProps> {
|
|
public readonly props: AnalyticsEntityIdProps;
|
|
|
|
private constructor(value: string) {
|
|
this.props = { value };
|
|
}
|
|
|
|
static create(raw: string): AnalyticsEntityId {
|
|
const value = raw.trim();
|
|
|
|
if (!value) {
|
|
throw new Error('AnalyticsEntityId must be a non-empty string');
|
|
}
|
|
|
|
return new AnalyticsEntityId(value);
|
|
}
|
|
|
|
get value(): string {
|
|
return this.props.value;
|
|
}
|
|
|
|
equals(other: IValueObject<AnalyticsEntityIdProps>): boolean {
|
|
return this.props.value === other.props.value;
|
|
}
|
|
} |