@munlib/common 1.0.180 → 1.0.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,12 @@ var request_validation_error_1 = require("../errors/request-validation-error");
|
|
|
6
6
|
var validateRequest = function (req, res, next) {
|
|
7
7
|
var errors = (0, express_validator_1.validationResult)(req);
|
|
8
8
|
if (!errors.isEmpty()) {
|
|
9
|
-
|
|
9
|
+
// Extraer el primer error y sus detalles personalizados (typeError y userMsg)
|
|
10
|
+
var firstError = errors.array()[0]; // Primer error encontrado
|
|
11
|
+
var typeError = firstError.msg.typeError || "VALIDATION_ERROR";
|
|
12
|
+
var userMsg = firstError.msg.userMsg || "Error de validación en la solicitud";
|
|
13
|
+
// Lanzar RequestValidationError con los campos personalizados
|
|
14
|
+
throw new request_validation_error_1.RequestValidationError(errors.array(), userMsg, typeError);
|
|
10
15
|
}
|
|
11
16
|
next();
|
|
12
17
|
};
|