Skip to main content
Module

x/cav/mod.ts>Parser

A server framework for Deno
Go to Latest
type alias Parser
Re-export
import { type Parser } from "https://deno.land/x/cav@0.0.21/mod.ts";

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.

To read more about Zod, visit https://github.com/colinhacks/zod.

Type Parameters

optional
I = unknown
optional
O = unknown
definition: (ParserFunction<I, O> | ParserObject<I, O>)