Skip to main content
Module

x/cav/parser.ts

A server framework for Deno
Go to Latest
import * as mod from "https://deno.land/x/cav@0.0.21/parser.ts";

Interfaces

A function that parses data. If data is not shaped as expected, an error should be thrown.

An object with a ParserFunction as its "parse" property. Zod compatible.

Type Aliases

Matches any kind of parser. Useful for type constraints.

An object or function responsible for parsing data or throwing errors if the data isn't shaped as expected. These can either be functions with a single data argument that return the parsed data or an object with a parse(data): unknown function property that does the same. Cav is specifically tuned to be compatible with (but not dependent on) Zod, a schema-based data parsing library. However, any parsing library can be used, as long as its parsers satisfy this Parser interface. (Let me know if more shapes should be supported in a github issue.) You can also write strongly-typed parsing functions and objects by hand if you don't want to use a third-party parsing library.

Extracts the input type of a given Parser.

Extracts the output type of a given Parser.