跳到技能内容
词映 AI导航
发现工具选型指南Skills 技能AI 快讯AI图片AI视频AI文档AI办公AI助手AI搜索AI编程AI音频AI设计AI智能体模型与开发AI学习模型评测AI提示词内容检测AI金融AI 3D扫描与识别其他工具跨境电商 AI
词映 AI导航
工具库Skills 技能
我的收藏
词映 AI导航
发现工具选型指南Skills 技能AI 快讯AI图片AI视频AI文档AI办公AI助手AI搜索AI编程AI音频AI设计AI智能体模型与开发AI学习模型评测AI提示词内容检测AI金融AI 3D扫描与识别其他工具跨境电商 AI
Skills directory/kid-sid/codex-spellbook/typescript

Codex Validate External JSON in Strict TypeScript with Zod

Accept external JSON as `unknown`, validate it at runtime, and keep success and error outcomes explicit.

中文

Install in Codex

Use a local TypeScript project with its chosen Zod version and test runner.

  1. Copy the pinned `skills/typescript/` directory into `.agents/skills/typescript/` in the project.
  2. Confirm strict `tsconfig` rules, the input boundary, and how the project represents errors.

Example task

Define string `title` and positive integer `pageSize`. Call `safeParse` with page size 20 and then with the string value `"20"`.

What to check

Valid data produces a typed result. The string page size is rejected with a field-specific issue.

Original SKILL.md on GitHub · Updated 2026-11-13

Frequently asked question

Do I still need runtime validation if I wrote an interface?

Files and network input still need runtime checks. Infer the TypeScript type from the schema to avoid maintaining both definitions.

Related skills from this repository

  • Codex Validate Python Input with Pydantic and pytest
Browse Codex skills in the Chinese directory
词映 AI 导航Skills 技能
工具分类全部工具已本地化技能选型指南AI 快讯