Open ChrisNixTriller opened 2 years ago
either
implementation just throws one of the errors it get from its internal items. I think it may be better to throw a custom error like "Can't find a valid type matching the either
statement" or something.
node: 16.14.0 typescript: 4.5.5 computed-types: 1.11.2
The error message above is
bar: Expect array to be minimum of 1 items (actual: 0)
. This makes sense for the value offoo === 'Y'
.Here's a curious observation... If I use
const obj = { foo: 'X', bar: [], baz: [] }
, then the error changes tofoo: Expect value to equal "Y"
. Two notes:foo
to be wrong, when arguably it's thebaz
array that's not matching the schema.X
andY
(apart from the order in theeither
definition), so one might expect the errors to be similar.Obviously, the analogous error occurs if I swap the order of the schemas in the
either
definition.This is really pedantic, I know. The library is great and hopefully this is just some useful feedback for thought.