Replies: 1 comment
-
Also, if I'm talking out my wrong end, please kindly let me know. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sorry for the ten thousandth post on this, but in the process of getting myself acquainted with the concepts and how zod implements this.
After having seen and read the various issues/discussions/pull requests, I wasn't sure if I should add my comments to the open issue (#3407), so I opted to post it here for discussion.
My gut feeling is most of the existing issues could be served by being able to match on multiple (optional) keys, but as I'm not familiar enough with zod, I am not sure if that's a viable strategy to implement and I did not want to add to the noise on that particular open issue.
In the mean time, considering that unions are evaluated in order, I'm pursuing this strategy and I wanted to get some opinions on this.
For a common type with and optional mutually exclusive index (either
readwrite
orrw
is to be used optionally but not concurrently), I'm testing the following:And for the following test data and linked Jest tests, it holds up.
Results from testing :
Full code in gist:
https://gist.github.com/TyIsI/a05bae503144028bc6fc44f573917018
Immediate caveats that come to mind are:
union
as a method at invocation time? - as opposed to parsing time)This at least solves my issue in the short term (and I can take the performance penalty for this particular use-case).
I figured I would post this for feedback.
Beta Was this translation helpful? Give feedback.
All reactions