chore: Made it possible to output multiple errors, not just the first one

This commit is contained in:
Danil 2025-04-11 11:45:53 +03:00
parent 7605c5190a
commit 97fa1bd066

View file

@ -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}`);
}
}