Skip to content
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

Open
vladshcherbin opened this issue Dec 8, 2024 · 3 comments
Assignees
Labels
fix A smaller enhancement or bug fix

Comments

@vladshcherbin
Copy link
Contributor

vladshcherbin commented Dec 8, 2024

I've tried switching from GenericSchema to ObjectSchema, checked suggested way in other issues and passed Schema type to flatten. For whatever reason the message type is unknown

Playground example

Error messages type:

image

If I remove Schema from flatten the type is array of strings:

Playground example

image

Is there a correct method that matches this types with schema defined?

valibot - 1.0.0-beta.9

@fabian-hiller
Copy link
Owner

fabian-hiller commented Dec 8, 2024

Schema is a generic ObjectSchema and will never be strongly typed. Therefore, passing Schema to flatten has no advantage. What behavior did you expect? Maybe there is something we can do better. We can try to produce a more useful type that does not resolve to [string, unknown][].

@fabian-hiller fabian-hiller self-assigned this Dec 8, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Dec 8, 2024
@vladshcherbin
Copy link
Contributor Author

@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 flatten.

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

@fabian-hiller
Copy link
Owner

I reopen it because I would like to have a look at it in the next weeks.

@fabian-hiller fabian-hiller added fix A smaller enhancement or bug fix and removed question Further information is requested labels Dec 9, 2024
@fabian-hiller fabian-hiller reopened this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A smaller enhancement or bug fix
Projects
None yet
Development

No branches or pull requests

2 participants