In TypeScript, you would write:
type A = ["A", ...string[]];
How would you define that type definition using Zod?
CodePudding user response:
According to the zod
documentation on tuples:
A variadic ("rest") argument can be added with the
.rest
method.
so a schema for your use case would look like:
const schema = z.tuple([z.literal('A')]).rest(z.string())