Zod type email string and number message not working correctly

Hey guys i am facing a issue i am also new to typescript

const authschem = z.object({
  email: z.union([
    z.string().email({ message: "Please enter a valid email address" }),
    z.number()
      .min(10, { message: "Invalid number" })
      .max(10, { message: "Invalid number" }),
  ]),
  password: z.string(),
});

i am using this type for react-hooks-forms and i want the email to either be string or number and when it is number show Invalid number message and when incorrect email message but it is only showing email message everytime how can i achive something like this
Was this page helpful?