import { z } from "zod";

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

export class TrackName {
  private readonly _value: string;

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

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

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

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

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

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