@pristine-ts/validation 0.0.296 → 0.0.298
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.
- package/dist/lib/cjs/interceptors/body-validation.request-interceptor.js +8 -0
- package/dist/lib/cjs/interceptors/body-validation.request-interceptor.js.map +1 -1
- package/dist/lib/esm/interceptors/body-validation.request-interceptor.js +9 -1
- package/dist/lib/esm/interceptors/body-validation.request-interceptor.js.map +1 -1
- package/dist/types/interceptors/body-validation.request-interceptor.d.ts +1 -0
- package/package.json +6 -6
|
@@ -46,6 +46,7 @@ let BodyValidationRequestInterceptor = class BodyValidationRequestInterceptor {
|
|
|
46
46
|
this.loghandler = loghandler;
|
|
47
47
|
this.validator = validator;
|
|
48
48
|
this.dataMapper = dataMapper;
|
|
49
|
+
this.priority = networking_1.RequestInterceptorPriorityEnum.BodyMapping - 100;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Intercepts the request and validates that the body of the request matches the expected class.
|
|
@@ -71,6 +72,13 @@ let BodyValidationRequestInterceptor = class BodyValidationRequestInterceptor {
|
|
|
71
72
|
if (errors.length == 0) {
|
|
72
73
|
return request;
|
|
73
74
|
}
|
|
75
|
+
this.loghandler.debug("BodyValidationRequestInterceptor - validation complete.", {
|
|
76
|
+
request,
|
|
77
|
+
methodNode,
|
|
78
|
+
routeContext: methodNode.route.context,
|
|
79
|
+
errors,
|
|
80
|
+
mappedBody,
|
|
81
|
+
}, validation_module_keyname_1.ValidationModuleKeyname);
|
|
74
82
|
// If we received some error while validating we reject by throwing an error.
|
|
75
83
|
throw new networking_1.BadRequestHttpError("Validation error", errors);
|
|
76
84
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-validation.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/body-validation.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,kEAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"body-validation.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/body-validation.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,kEAAuD;AACvD,wDAA4F;AAC5F,gDAAyF;AACzF,4EAAqE;AACrE,uCAA4C;AAG5C,uFAAsF;AACtF,0EAA4D;AAE5D;;;;GAIG;AAII,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IAEzC;;;;;;OAMG;IACH,YAA2C,UAAgD,EAC9D,SAAoB,EACpB,UAAsB;QAFS,eAAU,GAAV,UAAU,CAAqB;QAC9D,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QAInD,aAAQ,GAAG,2CAA8B,CAAC,WAAW,GAAG,GAAG,CAAC;IAF5D,CAAC;IAID;;;;;OAKG;IACG,gBAAgB,CAAC,OAAgB,EAAE,UAA4B;;YACjE,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,yDAA6B,CAAC,CAAC;YAE9E,IAAG,aAAa,KAAK,SAAS,IAAI,aAAa,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBACtE,OAAO,OAAO,CAAC;YACnB,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,+BAA+B,EAAE;gBACnD,OAAO;gBACP,UAAU;gBACV,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO;aACzC,EAAE,mDAAuB,CAAC,CAAA;YAE3B,6DAA6D;YAC7D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;YAExF,sEAAsE;YACtE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAEzD,IAAG,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACpB,OAAO,OAAO,CAAC;YACnB,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,yDAAyD,EAAE;gBAC7E,OAAO;gBACP,UAAU;gBACV,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO;gBACtC,MAAM;gBACN,UAAU;aACb,EAAE,mDAAuB,CAAC,CAAA;YAE3B,6EAA6E;YAC7E,MAAM,IAAI,gCAAmB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC;KAAA;CACJ,CAAA;AAzDY,4EAAgC;2CAAhC,gCAAgC;IAH5C,IAAA,qBAAY,EAAC,mDAAuB,CAAC;IACrC,IAAA,YAAG,EAAC,iCAAwB,CAAC,kBAAkB,CAAC;IAChD,IAAA,qBAAU,GAAE;IAUI,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;6CACF,2BAAS;QACR,gCAAU;GAX1C,gCAAgC,CAyD5C"}
|
|
@@ -20,7 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
import { Validator } from "@pristine-ts/class-validator";
|
|
23
|
-
import { BadRequestHttpError } from "@pristine-ts/networking";
|
|
23
|
+
import { BadRequestHttpError, RequestInterceptorPriorityEnum } from "@pristine-ts/networking";
|
|
24
24
|
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
25
25
|
import { ValidationModuleKeyname } from "../validation.module.keyname";
|
|
26
26
|
import { injectable, inject } from "tsyringe";
|
|
@@ -43,6 +43,7 @@ let BodyValidationRequestInterceptor = class BodyValidationRequestInterceptor {
|
|
|
43
43
|
this.loghandler = loghandler;
|
|
44
44
|
this.validator = validator;
|
|
45
45
|
this.dataMapper = dataMapper;
|
|
46
|
+
this.priority = RequestInterceptorPriorityEnum.BodyMapping - 100;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* Intercepts the request and validates that the body of the request matches the expected class.
|
|
@@ -68,6 +69,13 @@ let BodyValidationRequestInterceptor = class BodyValidationRequestInterceptor {
|
|
|
68
69
|
if (errors.length == 0) {
|
|
69
70
|
return request;
|
|
70
71
|
}
|
|
72
|
+
this.loghandler.debug("BodyValidationRequestInterceptor - validation complete.", {
|
|
73
|
+
request,
|
|
74
|
+
methodNode,
|
|
75
|
+
routeContext: methodNode.route.context,
|
|
76
|
+
errors,
|
|
77
|
+
mappedBody,
|
|
78
|
+
}, ValidationModuleKeyname);
|
|
71
79
|
// If we received some error while validating we reject by throwing an error.
|
|
72
80
|
throw new BadRequestHttpError("Validation error", errors);
|
|
73
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-validation.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/body-validation.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"body-validation.request-interceptor.js","sourceRoot":"","sources":["../../../../src/interceptors/body-validation.request-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAC,mBAAmB,EAAE,8BAA8B,EAAC,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAU,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAC;AAE5D;;;;GAIG;AAII,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;I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AC,CAAC;QAC9D,CAAC;KAAA;CACJ,CAAA;AAzDY,gCAAgC;IAH5C,YAAY,CAAC,uBAAuB,CAAC;IACrC,GAAG,CAAC,wBAAwB,CAAC,kBAAkB,CAAC;IAChD,UAAU,EAAE;IAUI,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;6CACF,SAAS;QACR,UAAU;GAX1C,gCAAgC,CAyD5C"}
|
|
@@ -20,6 +20,7 @@ export declare class BodyValidationRequestInterceptor implements RequestIntercep
|
|
|
20
20
|
* @param validator The validator that validates objects.
|
|
21
21
|
*/
|
|
22
22
|
constructor(loghandler: LogHandlerInterface, validator: Validator, dataMapper: DataMapper);
|
|
23
|
+
priority: number;
|
|
23
24
|
/**
|
|
24
25
|
* Intercepts the request and validates that the body of the request matches the expected class.
|
|
25
26
|
* It also validates the content of properties using the class-validator library.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/validation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.298",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/validation.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/validation.module.js",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@pristine-ts/class-validator": "^1.0.25",
|
|
16
|
-
"@pristine-ts/common": "^0.0.
|
|
17
|
-
"@pristine-ts/core": "^0.0.
|
|
18
|
-
"@pristine-ts/data-mapping": "^0.0.
|
|
19
|
-
"@pristine-ts/networking": "^0.0.
|
|
16
|
+
"@pristine-ts/common": "^0.0.298",
|
|
17
|
+
"@pristine-ts/core": "^0.0.298",
|
|
18
|
+
"@pristine-ts/data-mapping": "^0.0.298",
|
|
19
|
+
"@pristine-ts/networking": "^0.0.298"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"src/*.{js,ts}"
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "335e8aeb3641ed4ea466b6f2c43c9a6bac1d27dc"
|
|
64
64
|
}
|