Skip to content
Discussion options

You must be logged in to vote

If you won't fix it, do you advice on how to fix it ?

here you go, @JonathanCabezas :

const makeGreaterThanZeroIntFromStringSchemaWithExample = (example: string) => z
  .string()
  .example(example) // <—————
  .transform(Number)
  .pipe(z.number().int().min(0));

const PaginationSchema = z
  .object({
    limit: makeGreaterThanZeroIntFromStringSchemaWithExample("2")
      .optional()
      .describe("The number of items per page to return"),
    offset: makeGreaterThanZeroIntFromStringSchemaWithExample("1")
      .optional()
      .describe("The page wanted, starting from 0"),
  });

OR you can extract transformation and piping into such helper, but keep examples along with description:

c…

Replies: 4 comments

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
0 replies
Answer selected by RobinTail
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
wontfix This will not be worked on breaking Backward incompatible changes
2 participants
Converted from issue

This discussion was converted from issue #2958 on September 23, 2025 20:50.