nestjs-api-forge 1.0.3 → 1.0.4

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.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForgeValidationPipe = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const validation_exception_1 = require("../exceptions/validation.exception");
6
+ class ForgeValidationPipe extends common_1.ValidationPipe {
7
+ constructor(options = {}) {
8
+ super({
9
+ whitelist: true,
10
+ transform: true,
11
+ forbidNonWhitelisted: true,
12
+ ...options,
13
+ exceptionFactory: (errors) => new validation_exception_1.ValidationException(flattenErrors(errors)),
14
+ });
15
+ }
16
+ }
17
+ exports.ForgeValidationPipe = ForgeValidationPipe;
18
+ function flattenErrors(errors, parentField) {
19
+ const details = [];
20
+ for (const err of errors) {
21
+ const field = parentField ? `${parentField}.${err.property}` : err.property;
22
+ if (err.constraints) {
23
+ details.push({
24
+ field,
25
+ message: Object.values(err.constraints).join(', '),
26
+ });
27
+ }
28
+ if (err.children?.length) {
29
+ details.push(...flattenErrors(err.children, field));
30
+ }
31
+ }
32
+ return details;
33
+ }
34
+ //# sourceMappingURL=forge-validation.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge-validation.pipe.js","sourceRoot":"","sources":["../../src/pipes/forge-validation.pipe.ts"],"names":[],"mappings":";;;AAAA,2CAAwF;AACxF,6EAAyE;AAczE,MAAa,mBAAoB,SAAQ,uBAAc;IACrD,YAAY,UAAiC,EAAE;QAC7C,KAAK,CAAC;YACJ,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,oBAAoB,EAAE,IAAI;YAC1B,GAAG,OAAO;YACV,gBAAgB,EAAE,CAAC,MAAyB,EAAE,EAAE,CAC9C,IAAI,0CAAmB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SACjD,CAAC,CAAC;IACL,CAAC;CACF;AAXD,kDAWC;AAED,SAAS,aAAa,CACpB,MAAyB,EACzB,WAAoB;IAEpB,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;QAE5E,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK;gBACL,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './forge-validation.pipe';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./forge-validation.pipe"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pipes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}