UNPKG

@ai2070/l0

Version:

L0: The Missing Reliability Substrate for AI

36 lines (35 loc) 1 kB
function isZodSchema(value) { if (!value || typeof value !== "object") return false; const schema = value; return typeof schema.parse === "function" && typeof schema.safeParse === "function" && "_def" in schema; } function isZodError(error) { if (!error || typeof error !== "object") return false; const err = error; return err.name === "ZodError" && Array.isArray(err.issues) && typeof err.format === "function"; } function safeParse(schema, data) { const result = schema.safeParse(data); return result; } function getZodErrorMessages(error) { return error.issues.map((issue) => { const path = issue.path.length > 0 ? `${issue.path.join(".")}: ` : ""; return `${path}${issue.message}`; }); } function flattenZodError(error) { const flat = error.flatten(); return { formErrors: flat.formErrors, fieldErrors: flat.fieldErrors }; } export { flattenZodError, getZodErrorMessages, isZodError, isZodSchema, safeParse }; //# sourceMappingURL=zodCompat.js.map