import { zodResolver as baseZodResolver } from "@hookform/resolvers/zod"
import { ZodError } from "zod"

// Zod v4 renamed `error.errors` to `error.issues`, but @hookform/resolvers
// still expects the legacy `errors` getter. Patch the prototype once so every
// resolver consumer keeps working without duplicating validation logic.
if (typeof ZodError !== "undefined" && !("errors" in ZodError.prototype)) {
  Object.defineProperty(ZodError.prototype, "errors", {
    get() {
      return this.issues
    },
  })
}

export const zodResolver = baseZodResolver
