21 lines
534 B
TypeScript
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;
|
|
}
|
|
} |