Deno-supporting branch of Zod, a TypeScript-first schema validation library with static type inference.
Repository
Current version released
3 years ago
This is a Deno-supporting branch of Zod, a TypeScript-first schema validation library with static type inference.
Example
#!/usr/bin/env -S deno run
import z from "https://deno.land/x/doz/mod.ts";
const Location = z.object({
latitude: z.number(),
longitude: z.number(),
}).strict();
type Location = z.infer<typeof Location>;
const destination: Location = Location.parse(JSON.parse(`{
"latitude": 20,
"longitude": "zero"
}`));
error: Uncaught Error: [
{
"code": "invalid_type",
"expected": "number",
"received": "string",
"path": [
"longitude"
],
"message": "Expected number, received string"
}
]
const ERROR = new ZodError([]);
^
at ZodObject.parse (parser.ts:171:17)
at example.ts:11:30