How to add custom message on Zod tuple?

I want to return a custom message on a Zod tuple. I did not find any way to do that.

Returned message: Array must contain at least 4 element(s)

Code:

z.tuple([
    z.enum(),
    z.number(),
    z.string(),
    z.array(),
],
    { message: "Needs to be an array." })
    //.refine, .min, .length will not work here

What I tried

  • There are no .min, .length arguments to do a workarround
  • .refine will not be called — something else will call the message at first