import { RacingDomainValidationError } from '../../errors/RacingDomainError';

export class ResultsCount {
  private constructor(private readonly value: number) {}

  static create(value: number): ResultsCount {
    if (!Number.isInteger(value) || value < 0) {
      throw new RacingDomainValidationError('Results count must be a non-negative integer');
    }
    return new ResultsCount(value);
  }

  toNumber(): number {
    return this.value;
  }

  equals(other: ResultsCount): boolean {
    return this.value === other.value;
  }
}