@munlib/common 1.0.186 → 1.0.188
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CustomError } from './custom-error';
|
|
2
2
|
export declare class RequestValidationError extends CustomError {
|
|
3
|
-
|
|
3
|
+
msg: string;
|
|
4
4
|
typeMsg: string;
|
|
5
5
|
userMsg: string;
|
|
6
6
|
statusCode: number;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(msg: string, typeMsg?: string, userMsg?: string);
|
|
8
8
|
serializeErrors(): {
|
|
9
9
|
status: string;
|
|
10
|
-
msg:
|
|
10
|
+
msg: string;
|
|
11
11
|
code: string;
|
|
12
12
|
typeMsg: string;
|
|
13
13
|
userMsg: string;
|
|
@@ -21,11 +21,11 @@ var erroresStatus_1 = require("./erroresStatus");
|
|
|
21
21
|
var instituciones_pagos_1 = require("../events/types/instituciones-pagos");
|
|
22
22
|
var RequestValidationError = /** @class */ (function (_super) {
|
|
23
23
|
__extends(RequestValidationError, _super);
|
|
24
|
-
function RequestValidationError(
|
|
24
|
+
function RequestValidationError(msg, typeMsg, userMsg) {
|
|
25
25
|
if (typeMsg === void 0) { typeMsg = instituciones_pagos_1.ErrorCategories.SINTAX; }
|
|
26
26
|
if (userMsg === void 0) { userMsg = erroresStatus_1.ErrorController.getErrorMessage(instituciones_pagos_1.ErrorCategories.SINTAX); }
|
|
27
27
|
var _this = _super.call(this, 'Invalid request parameters', "", "") || this;
|
|
28
|
-
_this.
|
|
28
|
+
_this.msg = msg;
|
|
29
29
|
_this.typeMsg = typeMsg;
|
|
30
30
|
_this.userMsg = userMsg;
|
|
31
31
|
_this.statusCode = 400;
|
|
@@ -36,10 +36,10 @@ var RequestValidationError = /** @class */ (function (_super) {
|
|
|
36
36
|
return _this;
|
|
37
37
|
}
|
|
38
38
|
RequestValidationError.prototype.serializeErrors = function () {
|
|
39
|
-
console.log("******1111********", this.
|
|
39
|
+
console.log("******1111********", this.msg);
|
|
40
40
|
return {
|
|
41
41
|
status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()),
|
|
42
|
-
msg: this.
|
|
42
|
+
msg: this.msg,
|
|
43
43
|
code: this.statusCode.toString(),
|
|
44
44
|
typeMsg: this.typeMsg,
|
|
45
45
|
userMsg: this.userMsg
|
|
@@ -9,7 +9,7 @@ var validateRequest = function (req, res, next) {
|
|
|
9
9
|
var errors = (0, express_validator_1.validationResult)(req);
|
|
10
10
|
if (!errors.isEmpty()) {
|
|
11
11
|
// Extraer el primer error y sus detalles personalizados (typeError y userMsg)
|
|
12
|
-
var msg = errors.array()[0].msg; // Primer error encontrado
|
|
12
|
+
var msg = errors.array()[0].msg.msg; // Primer error encontrado
|
|
13
13
|
var typeMsg = msg.typeMsg || instituciones_pagos_1.ErrorCategories.SINTAX;
|
|
14
14
|
var userMsg = msg.userMsg || erroresStatus_1.ErrorController.getErrorMessage(instituciones_pagos_1.ErrorCategories.SINTAX);
|
|
15
15
|
// Lanzar RequestValidationError con los campos personalizados
|