@alt-stack/zod-error
v1.5.1
Published
Utilities for formatting ZodError for structured logging
Maintainers
Readme
@alt-stack/zod-error
Small formatting helpers for turning a Zod 4 ZodError into human-readable text or structured logging data.
Install
pnpm add @alt-stack/zod-error zodQuickstart
import { z } from "zod";
import {
zodErrorToString,
zodErrorToStructuredLog,
} from "@alt-stack/zod-error";
const parsed = z.object({ email: z.string().email() }).safeParse({
email: "not-an-email",
});
if (!parsed.success) {
console.error(zodErrorToString(parsed.error));
console.warn(zodErrorToStructuredLog(parsed.error));
}zodErrorToString emits path: message entries separated by semicolons. zodErrorToStructuredLog returns a StructuredLogError with type, message, issueCount, and normalized issues. Its optional input argument is included without redaction, so sanitize sensitive values before passing them.
Documentation
Development
From the repository root:
pnpm --filter @alt-stack/zod-error check-types
pnpm --filter @alt-stack/zod-error build