4 ms·
With Zod you can build a schema that would match an existing type. Typescript will complain if the schema you build does not match the type you are representin
by t1amat 1y ago
With Zod you can build a schema that would match an existing type. Typescript will complain if the schema you build does not match the type you are representing, which is helpful. From memory:
import { z } from ‘zod’
type Message = { body: string; }
const messageSchema: z.Type<Message> = z.object({ body: z.string() })