From 97fa1bd0665f9221577b1165cec87f4179be6b6b Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 11 Apr 2025 11:45:53 +0300 Subject: [PATCH] chore: Made it possible to output multiple errors, not just the first one --- models/Currency.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/Currency.js b/models/Currency.js index 75120fb..803dd08 100644 --- a/models/Currency.js +++ b/models/Currency.js @@ -28,7 +28,8 @@ async function validateCurrency(data) { const validatedData = await currencySchema.validateAsync(data); return validatedData; } catch (error) { - throw new Error(`Validation error \n${JSON.stringify(error.details[0], null, '\t')}`); + const errorMessages = error.details.map(e => e.message).join('; '); + throw new Error(`Validation error(s): ${errorMessages}`); } }