Open tristal opened 1 month ago
This also appears to affect Unions as well, following on from your example:
// Discriminated Union example
const A = Type.Object({
a: Type.String(),
b: Type.Optional(Type.Never()),
c: Type.Number()
});
const B = Type.Object({
a: Type.Optional(Type.Never()),
b: Type.String(),
c: Type.Number()
});
const C = Type.Union([A, B]);
In version 0.30
, running Value.Errors
on A
, B
and C
gives the following:
# Value.Errors(A, {})
> /a: Expected string
> /c: Expected number
> /a: Expected required property
> /c: Expected required property
# Value.Errors(B, {})
> /b: Expected string
> /c: Expected number
> /b: Expected required property
> /c: Expected required property
# Value.Errors(C, {})
> : Expected value of union
> /a: Expected string
> /c: Expected number
> /a: Expected required property
> /c: Expected required property
> /b: Expected string
> /c: Expected number
> /b: Expected required property
> /c: Expected required property
In version 0.31
onwards, it instead gives the following output where the errors are no longer propagating:
# Value.Errors(A, {})
> /a: Required property
> /c: Required property
> /a: Expected string
> /c: Expected number
# Value.Errors(B, {})
> /b: Required property
> /c: Required property
> /b: Expected string
> /c: Expected number
# Value.Errors(C, {})
> : Expected union value
It seems that intersects are not propagating up errors from nested intersects when calling
Value.Errors(T, value)
.For example:
Then doing
Value.Errors
call on both objects, yield:Is this expected?