SysProM
    Preparing search index...

    Function defineSchema

    • 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.

      Type Parameters

      • T extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

      Parameters

      • schema: T

        Zod schema to extend

      Returns T & { is(value: unknown): value is output<T> }

      The original schema augmented with an is guard

      const MySchema = defineSchema(z.string());
      if (MySchema.is(value)) { // value is string
      }