Skip to content

Can we send param with zod.parse() #1074

Answered by scotttrinh
caglar-yildiz asked this question in Q&A
Discussion options

You must be logged in to vote

In that case you'll need to make the schema dynamically within the request. A simple pseudo-code example:

function routeHandler(req) {
  const schema = z.object({
    params: z.object({
      _id: z.string({ required_error: getMessage(req.body.lang) }),
    }),
  });
  // can use the schema here for whatever validation you are trying to do
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by caglar-yildiz
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