From 30a7072716b87f3e0d40ea4fda3ca7cea9d5d65d Mon Sep 17 00:00:00 2001 From: Navin Moorthy Date: Wed, 29 Mar 2023 12:36:50 +0530 Subject: [PATCH] =?UTF-8?q?refactor(env):=20=E2=99=BB=EF=B8=8F=20update=20?= =?UTF-8?q?formatErrors=20function=20to=20give=20proper=20formated=20outpu?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/utils.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/env/utils.js b/env/utils.js index eff7bf4..16fff62 100644 --- a/env/utils.js +++ b/env/utils.js @@ -22,20 +22,11 @@ export const formatErrors = (errors) => { return Object.entries(errors) .map(([name, value]) => { - if (Array.isArray(value)) { - return `${name}: ${value.join(", ")}\n`; - } - - if (typeof value === "string") { - return `${name}: ${value}\n`; - } - - if (typeof value === "object") { - return `${name}: ${formatErrors(value)}`; + if (value && "_errors" in value) { + return `${name}: ${value._errors.join(", ")}\n`; } return null; }) - .filter(isNonNullable) - .join(""); + .filter(isNonNullable); };