import type { ZodError } from "zod";

export type FormErrors = Record<string, string[] | undefined>;

export function getFormErrors(error: ZodError): FormErrors {
  return error.flatten().fieldErrors;
}

export function getFirstFormError(error: ZodError) {
  return error.issues[0]?.message ?? "Please check the highlighted fields.";
}
