Skip to content
Sarj Code Standards

no-discarded-validation-result

Consume Zod validation outcomes and transformed outputs instead of discarding them.

Why

Ignoring safeParse loses failure information; ignoring a transformed parse result leaves callers using values without the declared defaults, coercions or normalization.

Fix

Capture or return the parsed output. Branch on safeParse success and use data. Plain throwing validation without output changes remains supported.

Examples

Before — flagged The normalized output is discarded
app.ts
import { z } from "zod";
z.string().trim().parse(raw);
After — preferred Return the parsed value
app.ts
import { z } from "zod";
function parse(raw: unknown) {
return z.string().trim().parse(raw);
}