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

export class ImageUrl {
  private constructor(private readonly value: string) {}

  static create(value: string): ImageUrl {
    if (!value || value.trim().length === 0) {
      throw new RacingDomainValidationError('Image URL cannot be empty');
    }
    // Basic URL validation
    try {
      new URL(value);
    } catch {
      throw new RacingDomainValidationError('Invalid image URL format');
    }
    return new ImageUrl(value.trim());
  }

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

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