Validating anything untrusted — form bodies, API payloads, env vars, query strings — with type inference, in a package small enough for edge functions.
Overview
parse / safeParse, objects, arrays, enums, unions and full type inference — plus coercion ("42" → 42, "true" → true) so one schema validates a JSON body and an HTML form. Field errors flatten() straight into a form. The validation you reach for, small enough to drop into any edge function.
parse() / safeParse() / Infer<>Validate and infer types.
Tips
Use `v.coerce.number()` / `v.coerce.boolean()` for FormData and query strings, which arrive as strings.
`schema.safeParse(x)` returns `{ success, data | error }`; call `error.flatten()` to get `{ field: message }` for forms.
`Infer<typeof schema>` gives you the exact TypeScript type — one source of truth for runtime and compile time.
Zero-dependency and isomorphic — safe to import on the server, in the browser, on the edge and in React Native. It tree-shakes, so you only ship what you import.
Watch out for
`.strict()` rejects unknown keys — pair it with `@lacspace/form`, which strips internal fields (honeypot, timestamp) before validation.