Files
gridpilot.gg/core/racing/domain/value-objects/LeagueTimezone.ts
2026-01-16 19:46:49 +01:00

33 lines
819 B
TypeScript

import type { ValueObject } from '@core/shared/domain/ValueObject';
import { RacingDomainValidationError } from '../errors/RacingDomainError';
export interface LeagueTimezoneProps {
id: string;
}
export class LeagueTimezone implements ValueObject<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: ValueObject<LeagueTimezoneProps>): boolean {
return this.props.id === other.props.id;
}
}