Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
8 replies
Smadger

Zod array of dates

Can someone help me validate that a variable is an array of exactly two dates and ideally in the future.

Here is what I've currently got.

However it allows an array of two nulls which isn't what I want.
date: z.array(z.date(), {
  required_error: "Departure & Return Date is required",
  invalid_type_error: "Departure & Return Date is required",
}),
Was this page helpful?