import * as valita from "https://deno.land/x/valita@v0.3.5/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")
Classes
A validator/parser marked as "optional", signifying that their value can be missing from the parsed object. | |
A base class for all concreate validators/parsers. | |
An error type representing one or more validation/parsing errors. |
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
T Err | A validation/parsing failure. |
Return the inferred output type of a validator. | |
T Ok | A successful validation/parsing result. |
A validation/parsing success or failure. |