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

[Feature] Discriminated unions (fast lookup) #1183

Open
jakubwolny opened this issue May 24, 2023 · 1 comment
Open

[Feature] Discriminated unions (fast lookup) #1183

jakubwolny opened this issue May 24, 2023 · 1 comment

Comments

@jakubwolny
Copy link
Contributor

Motivation:
I have a union of around 50 types, from which some are very complex. In this scenario input assertion takes significant time to be evaluated. As I understand superstruct union - it iterates over all union members until there's match. All of these types have a common field "type" which could be used for faster lookup.

Idea:
When checking around I noticed "zod" has something exactly like this
https://github.com/colinhacks/zod#discriminated-unions

Is this a feature you'd welcome in superstruct?

@birtles
Copy link
Contributor

birtles commented Sep 21, 2023

I made something up over in #897 (comment) for this but I've never got around to polishing it up to be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants