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;
  }
}