const mySchema = S.union(
S.struct({ _tag: 'A', value: S.string }),
S.struct({ _tag: 'B', value: S.number }),
)
S.parse(mySchema)({ _tag: 'B', "not a number" })
/* 2 errors found
─ union member
└─ ["_tag"]
└─ Expected "A", actual "B"
└─ union member
└─ ["value"]
└─ Expected "number", actual "not a number"
*/
const mySchema = S.union(
S.struct({ _tag: 'A', value: S.string }),
S.struct({ _tag: 'B', value: S.number }),
)
S.parse(mySchema)({ _tag: 'B', "not a number" })
/* 2 errors found
─ union member
└─ ["_tag"]
└─ Expected "A", actual "B"
└─ union member
└─ ["value"]
└─ Expected "number", actual "not a number"
*/