docs: update z.custom example for v4 compatibility#5763
Conversation
Remove template string literal example since z.templateLiteral is now available in Zod v4. Replace with File instanceof example which better demonstrates z.custom's use case for complex types. Fixes colinhacks#5605
The File example overlapped with z.file(); switch to a duck-typed PromiseLike example which doesn't have a built-in equivalent, and add cross-references to z.instanceof() and z.templateLiteral() for the cases the previous examples covered. Reverts the v3 README change since the template literal example is appropriate for v3.
|
TL;DR — Replaces the outdated Key changes
Summary | 1 file | 3 commits | base: The previous example used a
|
There was a problem hiding this comment.
No new issues. Reviewed the following changes:
- Replaced the
PromiseLikestructural duck-typing example with a simplerDecimal(fromdecimal.js) example forz.custom(), making the docs more approachable - Simplified the introductory text to focus on third-party library types rather than structural interfaces
- Preserved the cross-references to
z.instanceof()andz.templateLiteral()for related use cases
Claude Opus | 𝕏
|
Merged, thanks for chasing this down. I swapped the example to a Note: this comment was produced by an AI coding assistant. |
|
Landed in Zod 4.4 |
Remove template string literal example since z.templateLiteral is now available in Zod v4. Replace with File instanceof example which better demonstrates z.custom's use case for complex types.
Fixes #5605