import { json_schema } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { intersect } = json_schema;
Creates a JsonBuilder that intersects two JsonBuilders
Examples
Example 1
Example 1
import * as J from "./json_schema.ts";
import { pipe } from "./fn.ts";
// {
// "allOf": [
// {
// "type": "object",
// "properties": {
// "num": {
// "type": "number"
// }
// },
// "required": [
// "num"
// ]
// },
// {
// "type": "object",
// "properties": {
// "str": {
// "type": "string"
// }
// }
// }
// ]
// }
const schema = pipe(
J.struct({ num: J.number() }),
J.intersect(J.partial({ str: J.string() })),
J.print,
);
Parameters
and: JsonBuilder<I>
Returns
<A>(ta: JsonBuilder<A>) => JsonBuilder<A & I>