Merge of two enums zod

Viewed 11

I have 2 enums, const Option1 = z.enum(["option1"]) and const Option2 = z.enum(["option2"]). I want to merge these two into z.ZodEnum<["option1", "option2"]>

The only way I came up with so far is

export const Options = z.enum([
  ...Option1.options,
  ...Option2.options,
]);
// Options.options is now ["option1", "option2"]

Is there any zod native way to do this?

0 Answers
Related