From cca014922b772d096a8820dd16fa154760cf13d0 Mon Sep 17 00:00:00 2001 From: Aurelien BOUTEILLER Date: Wed, 21 Dec 2022 18:57:45 +0100 Subject: [PATCH] Add stringify on value if type of is 'object' --- src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 92df9755..135a8366 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -72,11 +72,12 @@ export function toFailure( const { path, branch } = context const { type } = struct + const finalValue = typeof value === 'object' ? JSON.stringify(value) : value const { refinement, message = `Expected a value of type \`${type}\`${ refinement ? ` with refinement \`${refinement}\`` : '' - }, but received: \`${print(value)}\``, + }, but received: \`${print(finalValue)}\``, } = result return {