Reputation: 11478
In TypeScript, you would write:
type A = ["A", ...string[]];
How would you define that type definition using Zod?
Upvotes: 6
Views: 3615
Reputation: 9836
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())
Upvotes: 6