export class VersionName {
  private constructor(private readonly _value: string) {}

  static create(value: string): VersionName {
    if (!value || value.trim().length === 0) {
      throw new Error('Version name cannot be empty')
    }
    // 支持 x.y.z 或 x.y.z.w 格式
    const pattern = /^\d+(\.\d+){1,3}$/
    if (!pattern.test(value.trim())) {
      throw new Error('Version name must be in format x.y.z or x.y.z.w')
    }
    return new VersionName(value.trim())
  }

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

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