Glossário

Glossary

abort (refinement option) — marks a .refine() as non-continuable; validation stops at the first failing abort-marked check instead of collecting all issues (Ch 25)

AOT compilation — compiling a schema into a specialized fast-path validator ahead of time, with identical results/errors to the standard parser (Ch 39)

branded type — a schema output type tagged with a phantom type marker (.brand<"Tag">()) to simulate nominal typing on top of TypeScript's structural types (Ch 30)

catch — a fallback value returned when parsing fails for any reason, via .catch(value) or .catch(fn) (Ch 29)

check — a post-parse validation or mutation attached to a schema that never changes its inferred type; the general mechanism behind .refine(), .min(), .trim(), etc. (Ch 25, Ch 52)

codec — a schema representing a bidirectional transformation between an input schema and an output schema, via decode/encode functions (Ch 26, Ch 36–38)

custom registry — a z.registry<MetaType>() instance for storing arbitrary strongly-typed metadata against schemas, distinct from z.globalRegistry (Ch 50)

default.default(value): supplies a value when input is undefined, short-circuiting the parse; the value must match the schema's output type (Ch 29)

discriminated unionz.discriminatedUnion(key, [...]): a union of object schemas sharing one literal "tag" field, enabling fast, precise parsing (Ch 20)

error map — a function (issue) => message | undefined used to customize validation error messages at the schema, per-parse, or global level (Ch 41–43)

exact optional.exactOptional(): allows a key to be absent but not explicitly set to undefined, matching TypeScript's exactOptionalPropertyTypes (Ch 13)

flattenErrorz.flattenError(): converts a ZodError into a shallow { formErrors, fieldErrors } object, best for one-level-deep schemas (Ch 44)

global registryz.globalRegistry: Zod's built-in registry for common metadata (id, title, description, deprecated), backing .meta()/.describe() (Ch 50)

issue — a structured object (code, path, message, plus type-specific fields) describing one validation failure; collected in ZodError.issues (Ch 34, Ch 52)

locale — a built-in translation of Zod's default error messages, loaded via z.config(en()) or similar; 50+ languages available (Ch 42)

loose objectz.looseObject(): an object schema that never sets additionalProperties: false and passes unknown keys through unchanged (Ch 15)

nullishz.nullish(): shorthand for optional and nullable combined, accepting undefined, null, or the underlying type (Ch 13)

pipe.pipe(): chains one schema's output into another schema's input, most commonly used with transforms (Ch 27)

prefault.prefault(value): a "pre-parse default" — substitutes a value for undefined input, but still runs the full parsing pipeline on it, unlike .default() (Ch 29)

prettifyErrorz.prettifyError(): renders a ZodError as a human-readable, multi-line string (Ch 44)

readonly.readonly(): marks a schema's inferred type as Readonly<...> and freezes the parsed result at runtime via Object.freeze() (Ch 30)

refinement — a custom validation function attached via .refine() that can reject a value but never changes its inferred type (Ch 25)

registry — a typed collection associating schemas with metadata; created via z.registry<MetaType>() (Ch 50)

safeParse.safeParse(input): validates and returns a { success, data } / { success: false, error } result object instead of throwing (Ch 34)

Standard Schema — a shared validation-library interface (implemented by Zod and others) for accepting user-defined schemas as black-box validators (Ch 48)

stringboolz.stringbool(): parses recognized truthy/falsy strings ("true", "yes", "0", etc.) into a real boolean (Ch 12)

strict objectz.strictObject(): an object schema that throws if the input has any key outside its declared shape (Ch 15)

template literal schemaz.templateLiteral([...]): a schema built from literal segments and sub-schemas, mirroring TypeScript's template literal types (Ch 7)

transform.transform(fn) / z.transform(fn): a one-way reshaping of a parsed value; the inverse-capable counterpart is a codec (Ch 28)

treeifyErrorz.treeifyError(): converts a ZodError into a nested object tree mirroring the schema's shape (Ch 44)

Zod Corezod/v4/core: the shared, method-free base package underlying both Zod and Zod Mini (Ch 51–52)

Zod Minizod/mini: a tree-shakable, functional-API variant of Zod with identical behavior but smaller bundles (Ch 53–54)

ZodError — the error class thrown/returned on validation failure; holds a .issues array (Ch 34)