import { z } from "zod";

export const getMinMax = (schema: z.ZodNumber | z.ZodDefault<z.ZodNumber>) => {
  const baseSchema =
    schema instanceof z.ZodDefault ? schema.removeDefault() : schema;
  const min =
    baseSchema._def.checks.find((c) => c.kind === "min")?.value ?? null;
  const max =
    baseSchema._def.checks.find((c) => c.kind === "max")?.value ?? null;
  return { min, max };
};
