David Huson
David Huson
TTCTheo's Typesafe Cult
Created by David Huson on 7/25/2024 in #questions
Weird field error with React Hook Form (using Shadcn Form)
Im working on an app using the T3 stack. Im using Shadcn for the form and using the React Hook Form useFieldArray hook to dynamically add and remove fields. The issue i am running into has to do with field validation. I defined a Zod schema for the form, but when i submit i get this error:
"errors": {
"": {
"message": "Required",
"type": "invalid_type"
}
}
"errors": {
"": {
"message": "Required",
"type": "invalid_type"
}
}
It seems to be referencing a field with a blank name, however if i take a look at the values object it seems that every field has a name.
"values" : {
"report": [
{
"number": "1244",
"Pt name": "John Does",
"readonly": "Placeholder",
"select": "option1",
"date": "2024-07-03T05:00:00.000Z"
}
]
}
"values" : {
"report": [
{
"number": "1244",
"Pt name": "John Does",
"readonly": "Placeholder",
"select": "option1",
"date": "2024-07-03T05:00:00.000Z"
}
]
}
Im not really sure what is causing this and i could not find anything like this online. Can someone please point me in the right direction? Im relatively new to both Zod and React Hook Form.
2 replies