-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Empty object type returned by flattening a Variant Schema #700
Comments
Yes, this is a known issue that will be fixed in the future. Currently there is a circular dependency that I need to investigate. See the code here. The simplest workaround for now is to simply not pass a generic to const { nested, root } = v.flatten(issues); |
You don't need to apologize, this library is the best validation tool out there! Thank you for the workaround! I think a better solution to this problem would be to use a union of objects instead. This returns the correct types for both the output and errors. But I'm seeing weird behavior. When I switch the variant schema to a union of objects, the nested errors is undefined and the root error = 'Invalid type: Expected Object but received Object'. Is this expected behavior? |
In my case they are optional undefined because we have no guarantee that every path has an issue. Please take a look at this playground and let me know if it looks good.
I do not have a better solution for this at the moment. This is a rare case, as you would normally use |
The example provided in the playground is exactly the behavior I was looking for! Closing this issue for now since I have implemented the work around you provided. Thank you for the help! |
This is fixed in v0.39.0 |
When I try to safe parse with a Variant schema, the nested issues have type =
{} | undefined
. Here's an example:Is there a fix / workaround to this issue?
The text was updated successfully, but these errors were encountered: