import { z } from "zod";

const CarClassSchema = z
  .string()
  .trim()
  .min(1, "Car class cannot be empty")
  .max(50, "Car class must be 50 characters or less");

export class CarClass {
  private readonly _value: string;

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

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

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

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

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

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