generated at
ValibotのIssue

全propertyに対して説明がある
ts
type BaseIssue = { // 必須情報 kind: 'schema' | 'validation' | 'transformation'; type: string; input: unknown; expected: string | null; received: string; message: string; // 任意情報 requirement?: unknown; path?: IssuePath; issues?: Issues; lang?: string; abortEarly?: boolean; abortPipeEarly?: boolean; skipPipe?: boolean; };
.path があるの便利そうだmrsekut
zodはpathが不明なので、leafなschemaに対するerrorがどこで起きたのか分かりづらかった
これでpathを作れる
ts
const dotPath = issue.path.map((item) => item.key).join('.');

valibot.flattenで見やすくできる
ts
import * as v from 'valibot'; const ObjectSchema = v.object({ key: v.string('Value of "key" is missing.'), nested: v.object({ key: v.string('Value of "nested.key" is missing.'), }), }); const result = v.safeParse(ObjectSchema, { nested: {} }); if (result.issues) { console.log(v.flatten<typeof ObjectSchema>(result.issues)); }