import * as valita from "https://deno.land/x/valita@v0.3.2/mod.ts";
Examples
Example 1
Example 1
import * as v from "@badrap/valita";
const vehicle = v.union(
v.object({ type: v.literal("plane"), airline: v.string() }),
v.object({ type: v.literal("train") }),
v.object({ type: v.literal("automobile"), make: v.string() })
);
vehicle.parse({ type: "bike" });
// ValitaError: invalid_literal at .type (expected "plane", "train" or "automobile")