import * as vi from "vitest"
import { z } from 'zod'
import { zx } from "@traversable/zod"
vi.expect.soft(zx.toString(
z.union([z.object({ tag: z.literal("Left") }), z.object({ tag: z.literal("Right") })])
)).toMatchInlineSnapshot
(`z.union([z.object({ tag: z.literal("Left") }), z.object({ tag: z.literal("Right") })]))`)
vi.expect.soft(zx.toString(
z.tuple([z.number().min(0).lt(2), z.number().multipleOf(2), z.number().max(2).nullable()])
)).toMatchInlineSnapshot
(`z.tuple([z.number().min(0).lt(2), z.number().multipleOf(2), z.number().max(2).nullable()])`)
zx.toString
Converts an arbitrary zod schema back into string form. Can be useful for code generation, testing/debugging, and the occasional sanity check.
import * as vi from "vitest"
import { z } from 'zod'
import { zx } from "@traversable/zod"
vi.expect.soft(zx.toString(
z.union([z.object({ tag: z.literal("Left") }), z.object({ tag: z.literal("Right") })])
)).toMatchInlineSnapshot
(`z.union([z.object({ tag: z.literal("Left") }), z.object({ tag: z.literal("Right") })]))`)
vi.expect.soft(zx.toString(
z.tuple([z.number().min(0).lt(2), z.number().multipleOf(2), z.number().max(2).nullable()])
)).toMatchInlineSnapshot
(`z.tuple([z.number().min(0).lt(2), z.number().multipleOf(2), z.number().max(2).nullable()])`)
zx.toString
Converts an arbitrary zod schema back into string form. Can be useful for code generation, testing/debugging, and the occasional sanity check.