Attach a type guard directly to a Zod schema.
This keeps the runtime validator, the inferred TypeScript type, and the runtime type guard derived from the same source.
Zod schema to extend
The original schema augmented with an is guard
is
const MySchema = defineSchema(z.string());if (MySchema.is(value)) { // value is string} Copy
const MySchema = defineSchema(z.string());if (MySchema.is(value)) { // value is string}
Attach a type guard directly to a Zod schema.
This keeps the runtime validator, the inferred TypeScript type, and the runtime type guard derived from the same source.