Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple environment support and cleanup #11

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
chore: minor changes to prettyPrintErrors function
  • Loading branch information
hassancodess committed Sep 14, 2024
commit ece9b3d94a16b32bd97fd7d96cde253a10307af3
16 changes: 7 additions & 9 deletions src/config/config.service.ts
Original file line number Diff line number Diff line change
@@ -3,16 +3,14 @@ import { z, ZodError } from 'zod';

dotenvx.config();

const prettyPrintErrors = (errObj: ZodError) => {
const formattedError = errObj.format();
const prettyPrintErrors = (errors: ZodError) => {
const formattedError = errors.flatten().fieldErrors;
Object.entries(formattedError).forEach(([key, value]) => {
if (key !== '_errors') {
console.log(`${key}:`);
if (Array.isArray(value?._errors)) {
value._errors.forEach((errorMessage: string) => {
console.log(` - ${errorMessage}`);
});
}
console.log(`${key}:`);
if (Array.isArray(value)) {
value.forEach((errorMessage: string) => {
console.log(` - ${errorMessage}`);
});
}
});
};