一覧へ戻る
true-myth/true-myth-zod(新しいタブで開きます)
主要言語: TypeScript
Integration between True Myth and Zod
- star 数
- 10
- watcher 数
- 0
- fork 数
- 0
- issue 数
- 6
- 最終更新
- 2026/05/05
主要言語: TypeScript
Integration between True Myth and Zod
A simple integration between True Myth and Zod.
This library intentionally does not bundle True Myth or Zod: it requires them as peer dependencies.
| package manager | command |
|---|---|
| pnpm | pnpm install true-myth zod true-myth-zod |
| yarn | yarn add true-myth zod true-myth-zod |
| npm | npm install true-myth zod true-myth-zod |
You must install a compatible version (pnpm and Yarn will check this for you):
| package | minimum version |
|---|---|
true-myth |
9.0.0 |
zod |
3.25.0 |
Write a schema with Zod, then wrap it with the parserFor or asyncParserFor functions exported by this library to produce a function that accepts unknown data and produces a True Myth Result (for sync parsing) or Task (for async parsing).
import * as z from 'zod/v4'; import { parserFor } from 'true-myth-zod'; // 1. Create the Zod schema. const UserSchema = z.object({ age: z.number(), name: z.string().optional(), }); // 2. Wrap it with `parserFor` to create a version that produces a True Myth // `Result` instead of Zod's const parseUser = parserFor(UserSchema); const input: unknown = { age: 42, name: "Reference Guy" }; parseUser(input).match({ Ok: (user) => { console.log(user.name ?? "someone", "is", user.age); }, Err: (parseError) => { console.error( `could not parse data: ${input}`, parseError.message, parseError.cause, ...parseError.issues, ); }, });
This library only depends on the zod/v4/core, so you can safely use it with either Zod or Zod Mini.