@traversable/schema
    Preparing search index...

    Function deepRequired

    • Converts an arbitrary zod schema into its "deeply-required" form.

      That just means that the schema will be traversed, and any z.optional z.optional nodes will be unwrapped.

      zx.deepRequired's behavior is configurable at the typelevel via the defaults.typelevel options.typelevel property:

      • defaults.typelevel "semantic" (default): leave the schema untouched, but wrap it in a no-op interface (zx.deepRequired.Semantic) to make things explicit

      • defaults.typelevel "applyToTypesOnly": apply the transformation to the schema's output type and wrap it in z.ZodType z.ZodType

      • defaults.typelevel "preserveSchemaType": zx.deepRequired will return what it got, type untouched

      Note:

      Make sure you understand the semantics of deepRequired before you use this in production. There's a reason it was removed from zod proper. This library trusts users to do their due diligence to make sure they understand the tradeoffs.

      Type Parameters

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

      Parameters

      • type: T
      • options: "preserveSchemaType"

      Returns T

      import * as vi from "vitest"
      import { zx } from "@traversable/zod"

      // Using `zx.deepRequired.writeable` here to make it easier to visualize `zx.deepRequired`'s behavior:
      vi.expect.soft(zx.deepRequired.writeable(
      z.object({
      a: z.optional(z.number()),
      b: z.optional(z.string()),
      c: z.object({
      d: z.optional(
      z.array(
      z.optional(
      z.object({
      e: z.number().max(1),
      f: z.optional(z.optional(z.boolean()))
      })
      )
      )
      )
      })
      })
      )).toMatchInlineSnapshot(
      `"z.object({
      a: z.number(),
      b: z.string(),
      c: z.object({
      d: z.array(
      z.object({
      e: z.number().max(1),
      f: z.boolean()
      })
      )
      })
      })"`
      )
    • Converts an arbitrary zod schema into its "deeply-required" form.

      That just means that the schema will be traversed, and any z.optional z.optional nodes will be unwrapped.

      zx.deepRequired's behavior is configurable at the typelevel via the defaults.typelevel options.typelevel property:

      • defaults.typelevel "semantic" (default): leave the schema untouched, but wrap it in a no-op interface (zx.deepRequired.Semantic) to make things explicit

      • defaults.typelevel "applyToTypesOnly": apply the transformation to the schema's output type and wrap it in z.ZodType z.ZodType

      • defaults.typelevel "preserveSchemaType": zx.deepRequired will return what it got, type untouched

      Note:

      Make sure you understand the semantics of deepRequired before you use this in production. There's a reason it was removed from zod proper. This library trusts users to do their due diligence to make sure they understand the tradeoffs.

      Type Parameters

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

      Parameters

      • type: T
      • options: "applyToOutputType"

      Returns ZodType<deepRequired<output<T>, Function | RegExp | Date>>

      import * as vi from "vitest"
      import { zx } from "@traversable/zod"

      // Using `zx.deepRequired.writeable` here to make it easier to visualize `zx.deepRequired`'s behavior:
      vi.expect.soft(zx.deepRequired.writeable(
      z.object({
      a: z.optional(z.number()),
      b: z.optional(z.string()),
      c: z.object({
      d: z.optional(
      z.array(
      z.optional(
      z.object({
      e: z.number().max(1),
      f: z.optional(z.optional(z.boolean()))
      })
      )
      )
      )
      })
      })
      )).toMatchInlineSnapshot(
      `"z.object({
      a: z.number(),
      b: z.string(),
      c: z.object({
      d: z.array(
      z.object({
      e: z.number().max(1),
      f: z.boolean()
      })
      )
      })
      })"`
      )
    • Converts an arbitrary zod schema into its "deeply-required" form.

      That just means that the schema will be traversed, and any z.optional z.optional nodes will be unwrapped.

      zx.deepRequired's behavior is configurable at the typelevel via the defaults.typelevel options.typelevel property:

      • defaults.typelevel "semantic" (default): leave the schema untouched, but wrap it in a no-op interface (zx.deepRequired.Semantic) to make things explicit

      • defaults.typelevel "applyToTypesOnly": apply the transformation to the schema's output type and wrap it in z.ZodType z.ZodType

      • defaults.typelevel "preserveSchemaType": zx.deepRequired will return what it got, type untouched

      Note:

      Make sure you understand the semantics of deepRequired before you use this in production. There's a reason it was removed from zod proper. This library trusts users to do their due diligence to make sure they understand the tradeoffs.

      Type Parameters

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

      Parameters

      • type: T
      • options: "semantic"

      Returns deepRequired.Semantic<T>

      import * as vi from "vitest"
      import { zx } from "@traversable/zod"

      // Using `zx.deepRequired.writeable` here to make it easier to visualize `zx.deepRequired`'s behavior:
      vi.expect.soft(zx.deepRequired.writeable(
      z.object({
      a: z.optional(z.number()),
      b: z.optional(z.string()),
      c: z.object({
      d: z.optional(
      z.array(
      z.optional(
      z.object({
      e: z.number().max(1),
      f: z.optional(z.optional(z.boolean()))
      })
      )
      )
      )
      })
      })
      )).toMatchInlineSnapshot(
      `"z.object({
      a: z.number(),
      b: z.string(),
      c: z.object({
      d: z.array(
      z.object({
      e: z.number().max(1),
      f: z.boolean()
      })
      )
      })
      })"`
      )
    • Converts an arbitrary zod schema into its "deeply-required" form.

      That just means that the schema will be traversed, and any z.optional z.optional nodes will be unwrapped.

      zx.deepRequired's behavior is configurable at the typelevel via the defaults.typelevel options.typelevel property:

      • defaults.typelevel "semantic" (default): leave the schema untouched, but wrap it in a no-op interface (zx.deepRequired.Semantic) to make things explicit

      • defaults.typelevel "applyToTypesOnly": apply the transformation to the schema's output type and wrap it in z.ZodType z.ZodType

      • defaults.typelevel "preserveSchemaType": zx.deepRequired will return what it got, type untouched

      Note:

      Make sure you understand the semantics of deepRequired before you use this in production. There's a reason it was removed from zod proper. This library trusts users to do their due diligence to make sure they understand the tradeoffs.

      Type Parameters

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

      Parameters

      • type: T

      Returns deepRequired.Semantic<T>

      import * as vi from "vitest"
      import { zx } from "@traversable/zod"

      // Using `zx.deepRequired.writeable` here to make it easier to visualize `zx.deepRequired`'s behavior:
      vi.expect.soft(zx.deepRequired.writeable(
      z.object({
      a: z.optional(z.number()),
      b: z.optional(z.string()),
      c: z.object({
      d: z.optional(
      z.array(
      z.optional(
      z.object({
      e: z.number().max(1),
      f: z.optional(z.optional(z.boolean()))
      })
      )
      )
      )
      })
      })
      )).toMatchInlineSnapshot(
      `"z.object({
      a: z.number(),
      b: z.string(),
      c: z.object({
      d: z.array(
      z.object({
      e: z.number().max(1),
      f: z.boolean()
      })
      )
      })
      })"`
      )