@gfticket/common
Version:
An auth package to make micro-service authentication easy to integrate for other services
23 lines (22 loc) • 813 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestValidationError = void 0;
const custom_error_1 = require("./custom-error");
class RequestValidationError extends custom_error_1.CustomError {
constructor(errors) {
super("Invalid request parameters");
this.errors = errors;
this.statusCode = 400;
// Only because I'm are extending a built-in class
Object.setPrototypeOf(this, RequestValidationError.prototype);
}
serializeErrors() {
return this.errors.map((error) => {
if (error.type === "field") {
return { message: error.msg, field: error.path };
}
return { message: error.msg };
});
}
}
exports.RequestValidationError = RequestValidationError;
;