FieldType detected as string, but it should be a number
I am creating my zod schema using orval from my openapi spec.
So the resulting schema looks like:
"costs": zod.number().or(zod.null()).optional(),
The FieldType is string in this case, so I always get the error "Number expected, received string".
When I change the schema it is working fine. Unfortunately this is not a good solution for me, as I want to generate the forms directly from the api definition.
"costs": zod.number().optional(),
Can I overwrite the type somehow or is there a chance this can be fixed?
Hi @sharenz , have you tried zod.number().nullish() yet?
I think it might work for you. LMK if not!
@sharenz I'm gonna close the issue but feel free to re-open it if it doesn't work
@gustavoguichard, I'm reopening this one because we should strive to support all possible ways of construing Zod schemas. Zod's API has grown a lot since the early days of Remix Forms, and now we need to catch up 😅
The only reason to close this one would be if we could not find a solution and gave up.
@sharenz, you are creating the schemas dynamically, right?
@danielweinmann Yes they are generated automatically.
In detail, I have a python backend using fastapi, which automatically generates the openapi spec. Then I am using "orval" to create the zod schema for my remix app.
I checked briefly and I am using the correct way in both projects to setup the schema. So I am not aware of a workaround which would allow me to change the generated schema.
Awesome, thanks! I don't think we'll be able to fix this before v3, but we plan to release v3 with a solution for this use case.