Files
gridpilot.gg/core/racing/domain/value-objects/LeagueTimezone.ts
2025-12-17 01:23:09 +01:00

33 lines
810 B
TypeScript

import { RacingDomainValidationError } from '../errors/RacingDomainError';
import type { IValueObject } from '@core/shared/domain';
export interface LeagueTimezoneProps {
id: string;
}
export class LeagueTimezone implements IValueObject<LeagueTimezoneProps> {
readonly id: string;
private constructor(id: string) {
this.id = id;
}
static create(id: string): LeagueTimezone {
if (!id || id.trim().length === 0) {
throw new RacingDomainValidationError('LeagueTimezone id must be a non-empty string');
}
return new LeagueTimezone(id.trim());
}
get props(): LeagueTimezoneProps {
return { id: this.id };
}
toString(): string {
return this.id;
}
equals(other: IValueObject<LeagueTimezoneProps>): boolean {
return this.props.id === other.props.id;
}
}