-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Unable to get nested errors messages type when schema type is passed in flatten #965
Comments
|
@fabian-hiller in one of issue code blocks I saw you've used it this way, that's why I've tried the same in my project and got to this question. I didn't specify schema type before in Since you've said there's no advantage I'd consider this resolved 🙌 p.s. It would be awesome if type was the same for schema/no schema to avoid such questions, but I'd consider this as low priority and this issue can serve as a reference |
I reopen it because I would like to have a look at it in the next weeks. |
I have investigated this issue further. It seems that this problem only occurs when using a generic. Therefore, it is probably not a problem we can fix simply by changing the type implementation of flatten. At least I have not found a solution yet. The following example works as expected without a generic. import * as v from 'valibot';
const flatErrors = v.flatten<v.ObjectSchema<v.ObjectEntries, undefined>>([] as any);
if (flatErrors.nested) {
const errors = Object.entries(flatErrors.nested); // [string, [string, ...string[]] | undefined][]
} |
I am closing this issue as I am not sure if there is anything we can do, but if we find a possible solution in the future, I will be happy to reopen it. |
I've tried switching from
GenericSchema
toObjectSchema
, checked suggested way in other issues and passedSchema
type toflatten
. For whatever reason themessage
type isunknown
Playground example
Error messages type:
If I remove
Schema
fromflatten
the type is array of strings:Playground example
Is there a correct method that matches this types with schema defined?
valibot - 1.0.0-beta.9
The text was updated successfully, but these errors were encountered: