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

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

  static create(value: string): CarName {
    if (!value || value.trim().length === 0) {
      throw new RacingDomainValidationError('Car name cannot be empty');
    }
    if (value.length > 100) {
      throw new RacingDomainValidationError('Car name cannot exceed 100 characters');
    }
    return new CarName(value.trim());
  }

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

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