You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Submit the empty form. Upon submitting, the validation is fired, and you should see 2 errors on each of the fields
Case 2 - Inpatient (Filled Form)
Give a first name and a last name (and add more if you'd like). Submit the form. You should see the updated values in the space below.
Case 3 - Outpatient (Empty Form) <== ERRONEOUS PART
If outpatient is selected, then it should bypass the validations, and submit the form
Expected behaviour
Upon submission with the Outpatient selection, it should bypass the validations. However, it still seems to enforce the selection. At first, I thought that it is probably an error with zod, so I looked into the matter there. However, upon closer inspection, I suspect that the matter lies with RHF.
FieldArrayWithId - type inference
If we select the passengers section, then the expectation is that `fields` would inherit only the `passengers` key. However, it still seems to inherit the entire object.
Breaks control as well
With this, I am unsure if the problem lies in RHF's inference, or in Zod's validations, or possibly both. Because ultimately, even if this component is working fine, the failed validations seem to be the problem. I think the only possible solution to this would be to split the form into 2 forms and trigger their validations separately.
This discussion was converted from issue #12880 on June 29, 2025 00:23.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.57.0
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/rhf-zod-array-of-objects-8wk5sp
Steps to reproduce
Case 1 - Inpatient (Empty Form)
Submit the empty form. Upon submitting, the validation is fired, and you should see 2 errors on each of the fields
Case 2 - Inpatient (Filled Form)
Give a first name and a last name (and add more if you'd like). Submit the form. You should see the updated values in the space below.
Case 3 - Outpatient (Empty Form) <== ERRONEOUS PART
If
outpatient
is selected, then it should bypass the validations, and submit the formExpected behaviour
Upon submission with the Outpatient selection, it should bypass the validations. However, it still seems to enforce the selection. At first, I thought that it is probably an error with zod, so I looked into the matter there. However, upon closer inspection, I suspect that the matter lies with RHF.
FieldArrayWithId - type inference
If we select the passengers section, then the expectation is that `fields` would inherit only the `passengers` key. However, it still seems to inherit the entire object.Breaks control as well
With this, I am unsure if the problem lies in RHF's inference, or in Zod's validations, or possibly both. Because ultimately, even if this component is working fine, the failed validations seem to be the problem. I think the only possible solution to this would be to split the form into 2 forms and trigger their validations separately.
What browsers are you seeing the problem on?
Chrome
Relevant log output
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions