import { RacingDomainValidationError } from '../../errors/RacingDomainError';
import type { IValueObject } from '@core/shared/domain';

export interface DriverIdProps {
  value: string;
}

export class DriverId implements IValueObject<DriverIdProps> {
  private constructor(private readonly value: string) {}

  static create(value: string): DriverId {
    if (!value || value.trim().length === 0) {
      throw new RacingDomainValidationError('Driver ID is required');
    }
    return new DriverId(value.trim());
  }

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

  equals(other: IValueObject<DriverIdProps>): boolean {
    return this.props.value === other.props.value;
  }

  get props(): DriverIdProps {
    return { value: this.value };
  }
}