import { struct } from "https://deno.land/x/fun@v2.0.0/decoder.ts";
A decoder over a heterogenous record type. This struct can have different values at each key, and the resultant decoder will ensure that each key matches its corresponding decoder.
Examples
Example 1
Example 1
import * as D from "./decoder.ts";
const person = D.struct({ name: D.string, age: D.number });
const result1 = person({}); // Left(DecodeError)
const result2 = person(null); // Left(DecodeError)
const result3 = person({ name: "Brandon" }); // Left(DecodeError)
const result4 = person({ name: "Brandon", age: 37 });
// Right({ name: "Brandon", age: 37 })