We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7.12.1
@mantine/form
Vite
Firefox
Consider following setup
import { useForm, zodResolver } from '@mantine/form'; import { z } from 'zod'; function Button() { const schema = z.object({ first: z.string(), second: z.string(), }).refine(() => false, { path: 'first' }); const form = useForm({ mode: 'uncontrolled', initialValues: {}, validate: zodResolver(schema), }); function handleSubmit() { console.debug(form.validate();) } return <button onClick={handleSubmit}>Click</button> ); }
Console output will be empty, even though validation returns errors.
No response
The problem is that after validation library check that all error paths matched current path: https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/form/src/validate/validate-field-value.ts#L15
For now there is only one workaround I found is to store errors in additional state and reset them to form:
import { useForm, zodResolver } from '@mantine/form'; import { z } from 'zod'; import { useState } from 'react'; function Button() { const [errors, setErrors] = useState<Record<string, any>>(); const schema = z.object({ first: z.string(), second: z.string(), }).refine(() => false, { path: 'first' }); const form = useForm({ mode: 'uncontrolled', initialValues: {}, validate: (values) => { const result = zodResolver(schema)(values); if (Object.keys(result)) { setErrors(result); } return result; }, }); useEffect(() => { form.setErrors(errors); }, [errors]); function handleSubmit() { console.debug(form.validate();) } return <button onClick={handleSubmit}>Click</button> }
The text was updated successfully, but these errors were encountered:
Please provide a sandbox with a minimal reproduction.
Sorry, something went wrong.
You are welcome to reopen the issue if you can provide further details
No branches or pull requests
Dependencies check up
What version of @mantine/* packages do you have in package.json?
7.12.1
What package has an issue?
@mantine/form
What framework do you use?
Vite
In which browsers you can reproduce the issue?
Firefox
Describe the bug
Consider following setup
Console output will be empty, even though validation returns errors.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
The problem is that after validation library check that all error paths matched current path: https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/form/src/validate/validate-field-value.ts#L15
For now there is only one workaround I found is to store errors in additional state and reset them to form:
Self-service
The text was updated successfully, but these errors were encountered: