prisma-error-formatter
Version:
A flexible and customizable Prisma error formatter to simplify and unify error handling in Prisma Client applications.
20 lines (19 loc) • 670 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseValidationErrors = parseValidationErrors;
function parseValidationErrors(errors) {
const result = [];
for (const error of errors) {
if (error.constraints && Object.keys(error.constraints).length > 0) {
const messages = Object.values(error.constraints).join(", ");
result.push({
path: error.property,
message: messages,
});
}
if (error.children && error.children.length > 0) {
result.push(...parseValidationErrors(error.children));
}
}
return result;
}