Skip to content

Commit

Permalink
refactor(env): ♻️ update formatErrors function to give proper formate…
Browse files Browse the repository at this point in the history
…d output
  • Loading branch information
navin-moorthy committed Mar 29, 2023
1 parent 6d971fb commit 30a7072
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions env/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit 30a7072

Please sign in to comment.