@traversable/schema
    Preparing search index...

    Function fromConstant

    • Convert a blob of JSON data into a zod schema that represents that blob's least upper bound.

      Type Parameters

      • S extends
            | undefined
            | null
            | string
            | number
            | bigint
            | boolean
            | symbol
            | RegExp
            | Date
            | { -readonly [K in string
            | number
            | symbol]: Mut<S[K], RegExp | Date> }

      Parameters

      • json: S

      Returns ZodType<S>

      import { zx } from '@traversable/zod'

      let schema = zx.fromConstant({ abc: 'ABC', def: [1, 2, 3] })
      // ^? let schema: z.ZodType<{ abc: "ABC", def: [1, 2, 3] }>

      console.log(zx.toString(schema))
      // => z.object({ abc: z.literal("ABC"), def: z.tuple([ z.literal(1), z.literal(2), z.literal(3) ]) })
    • Convert a blob of JSON data into a zod schema that represents that blob's least upper bound.

      Parameters

      Returns ZodUnknown

      import { zx } from '@traversable/zod'

      let schema = zx.fromConstant({ abc: 'ABC', def: [1, 2, 3] })
      // ^? let schema: z.ZodType<{ abc: "ABC", def: [1, 2, 3] }>

      console.log(zx.toString(schema))
      // => z.object({ abc: z.literal("ABC"), def: z.tuple([ z.literal(1), z.literal(2), z.literal(3) ]) })
    Index

    Properties

    Properties

    writeable: (json: Json.Fixpoint) => string

    Convert a blob of JSON data into a stringified zod schema that represents that blob's least upper bound.

    import { zx } from '@traversable/zod'

    let ex_01 = zx.fromConstant.writeable({ abc: 'ABC', def: [1, 2, 3] })

    console.log(ex_01)
    // => z.object({ abc: z.literal("ABC"), def: z.tuple([ z.literal(1), z.literal(2), z.literal(3) ]) })