Request a feature
🤷 Motivation
In a lot of cases, I find myself writing schemas that cause ParseErrors: An unordered union of a type including a morph and a type with overlapping input is indeterminate
I know the input overlaps, but I also have the context of my application and know which schema I was to prioritise. Currently, I do this to shoehorn in an ordered union:
const Thing = type({
myProp: type.unknown.pipe((v) =>
match
.case(TypeA, (v) => v)
.case(TypeB, (v) => v)
.default("reject")(v)
)
})
Playground Link w/ Example
But this has the downside of cutting off errors at the wrong "level" (see playground for comparison of errors this gets, vs what I'd expect).
💡 Solution
I would really like some of kind ordered union option, either by allowing us to drop matchers (i.e. match.case().case()) into a type, or by introducing something like type.firstMatch to make clear the first match behaviour.
Request a feature
🤷 Motivation
In a lot of cases, I find myself writing schemas that cause ParseErrors: An unordered union of a type including a morph and a type with overlapping input is indeterminate
I know the input overlaps, but I also have the context of my application and know which schema I was to prioritise. Currently, I do this to shoehorn in an ordered union:
Playground Link w/ Example
But this has the downside of cutting off errors at the wrong "level" (see playground for comparison of errors this gets, vs what I'd expect).
💡 Solution
I would really like some of kind ordered union option, either by allowing us to drop matchers (i.e.
match.case().case()) into atype, or by introducing something liketype.firstMatchto make clear the first match behaviour.