In the following code, during the validation function for users.tags.tag, the values parameter should contain data of type FormValues. However, it's incorrectly inferred as { tag: string; key: string; }.
import { randomId } from "@mantine/hooks";
import { useForm } from "@mantine/form";
type FormValues = {
users: {
name: string;
key: string;
tags: {
tag: string;
key: string;
}[];
}[];
};
export default function App() {
const initialValues: FormValues = {
users: [
{
name: "Dan Abramov",
key: randomId(),
tags: [{ tag: "React", key: randomId() }],
},
],
};
const form = useForm({
initialValues,
validate: {
users: {
name: (value, values, path) => {
console.log("validate users.name", { value, values, path });
if (value === "") return "Name is required";
return null;
},
tags: {
tag: (value, values, path) => {
// Here, the 'values' actually contains a value of type FormValues, but for some reason, it's inferred as { tag: string; key: string; }
console.log("validate users.tags.tag", { value, values, path });
if (value === "") return "Tag is required";
return null;
},
},
},
},
});
return <>{/* Omitted for brevity */}</>;
}
What version of @mantine/hooks page do you have in package.json?
6.0.20
If possible, please include a link to a codesandbox with the reproduced problem
What package has an issue
@mantine/form
Describe the bug
In the following code, during the validation function for
users.tags.tag
, the values parameter should contain data of typeFormValues
. However, it's incorrectly inferred as{ tag: string; key: string; }
.What version of @mantine/hooks page do you have in package.json?
6.0.20
If possible, please include a link to a codesandbox with the reproduced problem
https://codesandbox.io/s/nostalgic-wood-9dnyr6?file=/src/App.tsx
Do you know how to fix the issue
None
Are you willing to participate in fixing this issue and create a pull request with the fix
None
Possible fix
No response