Skip to content

Form schema validation incompatible with zod v4 #7871

@thj-dk

Description

@thj-dk

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

8.0.1

What package has an issue?

@mantine/form

What framework do you use?

Vite

In which browsers you can reproduce the issue?

All

Describe the bug

The ´zodResolver´ found in @mantine/form is not compatible with newly released zod v4.
The following sample throws the error:

Argument of type 'ZodObject<{ comment: ZodOptional<ZodString>; }, $strip>' is not assignable to parameter of type 'ZodSchema<Record<string, any>>'.
  The types returned by 'safeParse(...)' are incompatible between these types.
    Type 'ZodSafeParseResult<{ comment?: string | undefined; }>' is not assignable to type 'ZodParseSuccess | ZodParseError'.
      Type 'ZodSafeParseError<{ comment?: string | undefined; }>' is not assignable to type 'ZodParseSuccess | ZodParseError'.
        Type 'ZodSafeParseError<{ comment?: string | undefined; }>' is not assignable to type 'ZodParseError'.
          Types of property 'error' are incompatible.
            Property 'errors' is missing in type 'ZodError<{ comment?: string | undefined; }>' but required in type '{ errors: ZodError[]; }'.
import { Stack, TextInput } from "@mantine/core";
import { useForm, zodResolver } from "@mantine/form";
import { z } from "zod/v4";

const formSchema = z.object({
  comment: z.string().optional()
});

export const Form = () => {
  const form = useForm({
    validate: zodResolver(formSchema),
    initialValues: {
      comment: ""
    }
  });

  return (
    <form>
      <Stack>
        <TextInput
          {...form.getInputProps("comment")}
          label="Comment"
        />
      </Stack>
    </form>
  );
};

If possible, include a link to a codesandbox with a minimal reproduction

No response

Possible fix

No response

Self-service

  • I would be willing to implement a fix for this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions