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

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

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

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

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