mongoose-zod-error-formatter
Version:
A powerful error formatter utility for Mongoose and Zod validation errors, designed for Express.js applications. Simplify and unify your API error handling with structured, user-friendly error messages.
19 lines (18 loc) • 438 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatCastError = void 0;
const formatCastError = (error) => {
const errors = [
{
path: error.path,
message: "Invalid Id",
},
];
const statusCode = 400;
return {
statusCode,
message: "Cast Error",
errorMessages: errors,
};
};
exports.formatCastError = formatCastError;