@itzworking/decorated-class 0.0.144 → 0.0.146
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/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itzworking/decorated-class",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.146",
|
|
4
4
|
"private": false,
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2.3.0"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@itzworking/powertools": "0.0.144",
|
|
10
9
|
"reflect-metadata": "0.2.x"
|
|
11
10
|
},
|
|
12
11
|
"type": "commonjs",
|
package/src/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export type ArrayType<T> = T extends (infer U)[] ? U extends undefined | null ? (undefined | null)[] : OptionalProps<U>[] : T;
|
|
2
1
|
export type ObjectType<T> = T extends object ? T extends Function ? never : T extends undefined | null ? undefined | null : OptionalProps<T> : T;
|
|
3
2
|
export type OptionalProps<C> = undefined | null extends C ? undefined | null : ({
|
|
4
|
-
[Key in keyof C as C[Key] extends Function ? never : Key]?: C[Key] extends Array<any> ?
|
|
3
|
+
[Key in keyof C as C[Key] extends Function ? never : Key]?: C[Key] extends Array<any> ? C[Key] : ObjectType<C[Key]>;
|
|
5
4
|
} & Record<string, any>) | undefined | null;
|
|
@@ -4,7 +4,6 @@ exports.listValidationErrors = void 0;
|
|
|
4
4
|
const attribute_1 = require("../decorators/attribute");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
6
|
const decorated_class_1 = require("../decorated-class");
|
|
7
|
-
const powertools_1 = require("@itzworking/powertools");
|
|
8
7
|
const listValidationErrors = (target) => {
|
|
9
8
|
if (!target) {
|
|
10
9
|
throw new errors_1.InvalidTargetError("Target is not defined");
|
|
@@ -35,17 +34,9 @@ const listValidationErrors = (target) => {
|
|
|
35
34
|
}
|
|
36
35
|
if (attribute.attributeType === "Object" &&
|
|
37
36
|
attribute.nestedType &&
|
|
38
|
-
attribute.nestedType.prototype instanceof decorated_class_1.DecoratedClass
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
validations.push(...(0, exports.listValidationErrors)(target[attribute.attributeName]));
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
if (e instanceof errors_1.InvalidTargetError) {
|
|
45
|
-
powertools_1.logger.error(`Failed to validate nested object: ${attribute.attributeName}`);
|
|
46
|
-
}
|
|
47
|
-
throw e;
|
|
48
|
-
}
|
|
37
|
+
attribute.nestedType.prototype instanceof decorated_class_1.DecoratedClass &&
|
|
38
|
+
target[attribute.attributeName]) {
|
|
39
|
+
validations.push(...(0, exports.listValidationErrors)(target[attribute.attributeName]));
|
|
49
40
|
}
|
|
50
41
|
for (const validation of attribute.constraints) {
|
|
51
42
|
if (!validation.isValid(target)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-validation-errors.js","sourceRoot":"","sources":["../../../../../libs/decorated-class/src/validator/list-validation-errors.ts"],"names":[],"mappings":";;;AAAA,uDAAyD;AACzD,sCAAgE;AAChE,wDAAoD;
|
|
1
|
+
{"version":3,"file":"list-validation-errors.js","sourceRoot":"","sources":["../../../../../libs/decorated-class/src/validator/list-validation-errors.ts"],"names":[],"mappings":";;;AAAA,uDAAyD;AACzD,sCAAgE;AAChE,wDAAoD;AAE7C,MAAM,oBAAoB,GAAG,CAAC,MAAW,EAAE,EAAE;IAClD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,2BAAkB,CAAC,uBAAuB,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,UAAU,GAAG,IAAA,0BAAc,EAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAsB,EAAE,CAAC;IAC1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,aAAa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