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

export type ProtestStatusValue = 'pending' | 'awaiting_defense' | 'under_review' | 'upheld' | 'dismissed' | 'withdrawn';

export class ProtestStatus {
  private constructor(private readonly value: ProtestStatusValue) {}

  static create(value: string): ProtestStatus {
    const validStatuses: ProtestStatusValue[] = ['pending', 'awaiting_defense', 'under_review', 'upheld', 'dismissed', 'withdrawn'];

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

    return new ProtestStatus(value as ProtestStatusValue);
  }

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

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