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

export type PenaltyStatusValue = 'pending' | 'applied' | 'appealed' | 'overturned';

export class PenaltyStatus {
  private constructor(private readonly value: PenaltyStatusValue) {}

  static create(value: string): PenaltyStatus {
    const validStatuses: PenaltyStatusValue[] = ['pending', 'applied', 'appealed', 'overturned'];

    if (!validStatuses.includes(value as PenaltyStatusValue)) {
      throw new RacingDomainValidationError(`Invalid penalty status: ${value}`);
    }

    return new PenaltyStatus(value as PenaltyStatusValue);
  }

  toString(): PenaltyStatusValue {
    return this.value;
  }

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