import { z } from "zod";

const CarNameSchema = z
  .string()
  .trim()
  .min(1, "Car name cannot be empty")
  .max(100, "Car name must be 100 characters or less");

export class CarName {
  private readonly _value: string;

  private constructor(value: string) {
    this._value = value;
  }

  static create(value: string): CarName {
    const validated = CarNameSchema.parse(value);
    return new CarName(validated);
  }

  static fromString(value: string): CarName {
    return new CarName(value);
  }

  get value(): string {
    return this._value;
  }

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

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