import * as valita from "https://deno.land/x/valita@v0.3.3/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")
Functions
Create a validator for an array type | |
Create a validator that matches any bigint value. | |
Create a validator that matches any boolean value. | |
f err | Create a value for returning a parsing error from chain(). |
f lazy | Create a validator that can reference itself, directly or indirectly. |
Create a validator for a specific string, number, bigint or boolean value. | |
Create a validator that never matches any value,
analogous to the TypeScript type | |
f null | Create a validator that matches |
Create a validator that matches any number value. | |
Create a validator for an object type. | |
f ok | |
Create a validator for a record type | |
Create a validator that matches any string value. | |
Create a validator for an array type | |
Create a validator that matches | |
Create a validator that matches any type | |
Create a validator that matches any value,
analogous to the TypeScript type |
Type Aliases
Return the inferred output type of a validator. | |