Skip to content
Discussion options

You must be logged in to vote

@ThomasKientz , the augmentation implemented in Zod Plugin works on the level of prototypes (as it was recommended by Colin, the creator or Zod). It makes the custom methods (such as .example()) to exist on every instance of ZodType and it's enough just to import the plugin to do that.

The suggested idea of making a function like augment() is nice, but it would only work for the argument directly, but it won't work for chained calls like this:

schema
  .example()
  .describe()
  .example() // <— this will not work

because Zod methods are immutable — every method you call creates a new instance with a set of methods from its prototype.

Luckily, with Zod 4 the .example() method is just a sy…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@RobinTail
Comment options

Answer selected by RobinTail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3019 on October 23, 2025 12:34.