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

26 lines
660 B
TypeScript

import type { ValueObject } from '@core/shared/domain/ValueObject';
import { RacingDomainValidationError } from '../errors/RacingDomainError';
export class IRacingId implements ValueObject<string> {
private constructor(private readonly value: string) {}
static create(value: string): IRacingId {
if (!value || value.trim().length === 0) {
throw new RacingDomainValidationError('iRacing ID is required');
}
return new IRacingId(value);
}
toString(): string {
return this.value;
}
get props(): string {
return this.value;
}
equals(other: ValueObject<string>): boolean {
return this.props === other.props;
}
}