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

export type PrizeStatusValue = 'pending' | 'awarded' | 'paid' | 'cancelled';

export class PrizeStatus {
  private constructor(private readonly value: PrizeStatusValue) {}

  static create(value: string): PrizeStatus {
    const validStatuses: PrizeStatusValue[] = ['pending', 'awarded', 'paid', 'cancelled'];

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

    return new PrizeStatus(value as PrizeStatusValue);
  }

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

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