-
-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
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
yupResolver() type mismatch with useForm() when required() on field with null default value #589
Comments
Hi, I have the same issue, and opened discussion here (still no replies) |
I think my problem is also related: https://github.com/orgs/react-hook-form/discussions/10660 |
Related to #575 |
asegarra suggestion fixed the issue https://github.com/react-hook-form/resolvers/issues/575#issuecomment-1693405121 Adding NULL as a possible value for the input(select) in the FormInputType and specifying this type was accepted and now there are no type errors. |
@ypresto |
Describe the bug
Since v3.1.1, yupResolver() causes type mismatch between
required()
field and null value in defaultValues.Probably caused by this PR: #563
@hookform/resolvers: v3.1.1
react-hook-form: v7.45.1
yup: v1.2.0
To Reproduce
useForm({ defaultValues, resolver: yupResolver(validationSchema) })
.food
in codesandbox) to defaultValues (or justdefaultValues: { food: null }
).food
) asstring().required()
in validationSchema.useForm(...)
.One example of type error:
Codesandbox link (Required)
https://codesandbox.io/s/react-hook-form-yupresolver-null-type-error-with-tfieldvalues-cd3tcc?file=/src/App.tsx:842-873
(Note: template for yupResolver is too old as it uses v6 of react-hook-form.)
Expected behavior
No type error found.
Note that react-select will set the value to null when it is cleared.
The text was updated successfully, but these errors were encountered: