diff --git a/src/structs/types.ts b/src/structs/types.ts index f91d17ac..bd7ab38a 100644 --- a/src/structs/types.ts +++ b/src/structs/types.ts @@ -522,10 +522,15 @@ export function union( } } + const hint = failures.find((failure) => failure.path) + const hintMessage = hint + ? `\n\tAt key \`${hint.path}\` -- ${hint.message}` + : '' + return [ `Expected the value to satisfy a union of \`${description}\`, but received: ${print( value - )}`, + )}${hintMessage}`, ...failures, ] },