TanStackT
TanStack10mo ago
6 replies
colossal-harlequin

Form field error type

Hi there!

I'm using TanStack form with Zod Validation and was wondering if it's correct, that errors are of type any and I have to cast them to ZodIssue. I followed the basics examples on the website. Am I missing something?

Form looks like this:

  const form = useAppForm({
    defaultValues: {
      email: "",
      password: "",
    },
    validators: {
      onSubmit: z.object({
        email: z.string().email(),
        password: z.string().min(8, "Password is too short"),
      }),
    },
    onSubmit: ({ value }) => {
      loginMutation.mutate(value);
    },
  });
Screenshot_2025-04-07_at_16.58.16.png
Was this page helpful?