Skip to main content
Module

x/fun/json_schema.ts>struct

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function struct
import { struct } from "https://deno.land/x/fun@v2.0.0/json_schema.ts";

Creates a JsonBuilder of a struct with values and keys that match the supplied JsonBuilders

Examples

Example 1

import * as J from "./json_schema.ts";
import { pipe } from "./fn.ts";

// {
//   type: "object",
//   properties: { num: { type: "number" }, str: { type: "string" } },
//   required: [ "num", "str" ]
// }
const schema = J.print(J.struct({
  num: J.number(),
  str: J.string()
}));

Parameters

items: [K in keyof A]: JsonBuilder<A[K]>

Returns

JsonBuilder<readonly [K in keyof A]: A[K]>