Skip to content

no-impossible-zod-literal-bounds

Disallow same-chain literal Zod bounds whose accepted set is mathematically empty.

Why

A schema with contradictory literal bounds rejects every input, turning validation into an unreachable contract that usually reflects a typo.

Fix

Choose compatible lower and upper bounds, or remove the constraint that does not express the intended domain.

Examples

Before — flagged Reject an empty numeric interval
src/schema.ts
import { z } from "zod";
const S = z.number().min(5).max(4);
After — preferred Allow a number admitted by both bounds
src/schema.ts
import { z } from "zod";
const S = z.number().gte(3).lte(3);

Options

{
"additionalProperties": false,
"properties": {
"delegateRealContradictions": {
"description": "Let enabled upstream zod/no-conflicting-checks own explicit real-bound contradictions.",
"type": "boolean"
}
},
"type": "object"
}