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

20 lines
542 B
TypeScript

import { RacingDomainValidationError } from '../../errors/RacingDomainError';
export class IncidentCount {
private constructor(private readonly value: number) {}
static create(value: number): IncidentCount {
if (!Number.isInteger(value) || value < 0) {
throw new RacingDomainValidationError('Incident count must be a non-negative integer');
}
return new IncidentCount(value);
}
toNumber(): number {
return this.value;
}
equals(other: IncidentCount): boolean {
return this.value === other.value;
}
}