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.
- Copy the pinned `skills/typescript/` directory into `.agents/skills/typescript/` in the project.
- 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
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.