Files
gridpilot.gg/core/racing/domain/entities/penalty/PenaltyReason.ts
2025-12-17 00:33:13 +01:00

21 lines
534 B
TypeScript

import { RacingDomainValidationError } from '../../errors/RacingDomainError';
export class PenaltyReason {
private constructor(private readonly value: string) {}
static create(value: string): PenaltyReason {
const trimmed = value.trim();
if (!trimmed) {
throw new RacingDomainValidationError('Penalty reason cannot be empty');
}
return new PenaltyReason(trimmed);
}
toString(): string {
return this.value;
}
equals(other: PenaltyReason): boolean {
return this.value === other.value;
}
}