xdbc 1.0.207 → 1.0.209
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/Assessment.html +350 -0
- package/Assessment.md +507 -51
- package/CHANGELOG.md +55 -0
- package/CONTRIBUTING.md +129 -17
- package/README.md +373 -71
- package/SECURITY.md +60 -18
- package/SUPPORT.md +65 -0
- package/__tests__/DBC/DEFINED.test.ts +53 -0
- package/__tests__/DBC/Decorators.test.ts +365 -0
- package/__tests__/DBC/GREATER.test.ts +8 -6
- package/__tests__/DBC/HasAttribute.test.ts +56 -0
- package/__tests__/DBC/IF.test.ts +52 -0
- package/__tests__/DBC/JSON.Parse.test.ts +1 -1
- package/__tests__/DBC/OR.test.ts +1 -1
- package/__tests__/DBC/REGEX.test.ts +1 -1
- package/__tests__/DBC/TYPE.test.ts +1 -1
- package/__tests__/DBC/UNDEFINED.test.ts +45 -0
- package/__tests__/DBC/ZOD.test.ts +54 -0
- package/jest.config.js +21 -0
- package/package.json +4 -5
- package/src/DBC/AE.ts +10 -6
- package/src/DBC/COMPARISON/GREATER.ts +11 -7
- package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +14 -10
- package/src/DBC/COMPARISON/LESS.ts +14 -10
- package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +14 -10
- package/src/DBC/COMPARISON.ts +20 -43
- package/src/DBC/DEFINED.ts +4 -23
- package/src/DBC/EQ/DIFFERENT.ts +21 -56
- package/src/DBC/EQ.ts +7 -26
- package/src/DBC/HasAttribute.ts +9 -26
- package/src/DBC/IF.ts +8 -27
- package/src/DBC/INSTANCE.ts +5 -22
- package/src/DBC/JSON.OP.ts +4 -34
- package/src/DBC/JSON.Parse.ts +5 -25
- package/src/DBC/OR.ts +5 -14
- package/src/DBC/REGEX.ts +41 -40
- package/src/DBC/TYPE.ts +6 -25
- package/src/DBC/UNDEFINED.ts +3 -22
- package/src/DBC/ZOD.ts +10 -27
- package/src/DBC.ts +223 -55
- package/tsconfig.json +7 -4
- package/tsconfig.test.json +12 -0
- package/.parcel-cache/bf96c58b6061a62a-BundleGraph +0 -0
- package/.parcel-cache/d7c812d65aeeac59-AssetGraph +0 -0
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/e81759c1f106a17f-RequestGraph +0 -0
- package/.parcel-cache/fe0db3c4eb428be2-AssetGraph +0 -0
- package/.parcel-cache/lock.mdb +0 -0
- package/.parcel-cache/snapshot-e81759c1f106a17f.txt +0 -4609
- package/dist/DBC/AE.js +0 -173
- package/dist/DBC/COMPARISON/GREATER.js +0 -21
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +0 -21
- package/dist/DBC/COMPARISON/LESS.js +0 -21
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +0 -21
- package/dist/DBC/COMPARISON.js +0 -99
- package/dist/DBC/DEFINED.js +0 -99
- package/dist/DBC/EQ/DIFFERENT.js +0 -21
- package/dist/DBC/EQ.js +0 -100
- package/dist/DBC/GREATER.js +0 -99
- package/dist/DBC/HasAttribute.js +0 -108
- package/dist/DBC/IF.js +0 -99
- package/dist/DBC/INSTANCE.js +0 -93
- package/dist/DBC/JSON.OP.js +0 -133
- package/dist/DBC/JSON.Parse.js +0 -114
- package/dist/DBC/OR.js +0 -113
- package/dist/DBC/REGEX.js +0 -110
- package/dist/DBC/TYPE.js +0 -87
- package/dist/DBC/ZOD.js +0 -114
- package/dist/DBC.js +0 -336
- package/dist/Demo.js +0 -290
- package/dist/Test.html +0 -18
- package/dist/bundle.js +0 -2064
- package/dist/index.html +0 -18
- package/jest.config.ts +0 -20
- package/xpackage-lock.json +0 -122
package/src/DBC/DEFINED.ts
CHANGED
|
@@ -38,19 +38,7 @@ export class DEFINED extends DBC {
|
|
|
38
38
|
methodName: string | symbol,
|
|
39
39
|
parameterIndex: number,
|
|
40
40
|
) => void {
|
|
41
|
-
return DBC.
|
|
42
|
-
(
|
|
43
|
-
value: object,
|
|
44
|
-
target: object,
|
|
45
|
-
methodName: string,
|
|
46
|
-
parameterIndex: number,
|
|
47
|
-
) => {
|
|
48
|
-
return DEFINED.checkAlgorithm(value);
|
|
49
|
-
},
|
|
50
|
-
dbc,
|
|
51
|
-
path,
|
|
52
|
-
hint
|
|
53
|
-
);
|
|
41
|
+
return DBC.createPRE(DEFINED.checkAlgorithm, [], dbc, path, hint);
|
|
54
42
|
}
|
|
55
43
|
/**
|
|
56
44
|
* A method-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -71,14 +59,7 @@ export class DEFINED extends DBC {
|
|
|
71
59
|
propertyKey: string,
|
|
72
60
|
descriptor: PropertyDescriptor,
|
|
73
61
|
) => PropertyDescriptor {
|
|
74
|
-
return DBC.
|
|
75
|
-
(value: object, target: object, propertyKey: string) => {
|
|
76
|
-
return DEFINED.checkAlgorithm(value);
|
|
77
|
-
},
|
|
78
|
-
dbc,
|
|
79
|
-
path,
|
|
80
|
-
hint
|
|
81
|
-
);
|
|
62
|
+
return DBC.createPOST(DEFINED.checkAlgorithm, [], dbc, path, hint);
|
|
82
63
|
}
|
|
83
64
|
/**
|
|
84
65
|
* A field-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -95,7 +76,7 @@ export class DEFINED extends DBC {
|
|
|
95
76
|
hint: string | undefined = undefined,
|
|
96
77
|
dbc: string | undefined = undefined,
|
|
97
78
|
) {
|
|
98
|
-
return DBC.
|
|
79
|
+
return DBC.createINVARIANT(DEFINED, [], dbc, path, hint);
|
|
99
80
|
}
|
|
100
81
|
// #endregion Condition checking.
|
|
101
82
|
// #region Referenced Condition checking.
|
|
@@ -121,7 +102,7 @@ export class DEFINED extends DBC {
|
|
|
121
102
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link DEFINED }.
|
|
122
103
|
*
|
|
123
104
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }.*/
|
|
124
|
-
public static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
|
|
105
|
+
public static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
|
|
125
106
|
const result = DEFINED.checkAlgorithm(toCheck);
|
|
126
107
|
|
|
127
108
|
if (result === true) {
|
package/src/DBC/EQ/DIFFERENT.ts
CHANGED
|
@@ -14,79 +14,44 @@ import { EQ } from "../EQ";
|
|
|
14
14
|
* @see {@link EQ}
|
|
15
15
|
*/
|
|
16
16
|
export class DIFFERENT extends EQ {
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
* @param equivalent - The value to compare for inequality
|
|
20
|
-
* @param path - The property path
|
|
21
|
-
* @param hint - Optional hint message
|
|
22
|
-
*/
|
|
23
|
-
public static override PRE(
|
|
24
|
-
equivalent,
|
|
25
|
-
path,
|
|
26
|
-
hint
|
|
27
|
-
);
|
|
28
|
-
/**
|
|
29
|
-
* Precondition overload signature.
|
|
30
|
-
* @param equivalent - The value to compare for inequality
|
|
31
|
-
* @param path - The property path
|
|
32
|
-
*/
|
|
17
|
+
/** See {@link EQ.PRE }. Always inverts equality check. */
|
|
18
|
+
// biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
|
|
33
19
|
public static override PRE(
|
|
34
|
-
equivalent,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/** See {@link COMPARISON.PRE }. */
|
|
38
|
-
public static override PRE(
|
|
39
|
-
equivalent,
|
|
40
|
-
invert: boolean = false,
|
|
41
|
-
path: string = undefined,
|
|
20
|
+
equivalent: any,
|
|
21
|
+
_invert = false,
|
|
22
|
+
path: string | undefined = undefined,
|
|
42
23
|
hint: string | undefined = undefined,
|
|
43
24
|
dbc: string | undefined = undefined,
|
|
44
25
|
) {
|
|
45
|
-
return EQ.PRE(equivalent, true, path,
|
|
26
|
+
return EQ.PRE(equivalent, true, path, hint, dbc);
|
|
46
27
|
}
|
|
47
28
|
|
|
29
|
+
/** See {@link EQ.POST }. Always inverts equality check. */
|
|
30
|
+
// biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
|
|
48
31
|
public static override POST(
|
|
49
|
-
equivalent,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
-
public static override POST(
|
|
54
|
-
equivalent,
|
|
55
|
-
path,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
/** See {@link COMPARISON.POST }. */
|
|
59
|
-
public static override POST(
|
|
60
|
-
equivalent,
|
|
61
|
-
invert = false,
|
|
62
|
-
path: string = undefined,
|
|
32
|
+
equivalent: any,
|
|
33
|
+
_invert = false,
|
|
34
|
+
path: string | undefined = undefined,
|
|
63
35
|
hint: string | undefined = undefined,
|
|
64
36
|
dbc: string | undefined = undefined,
|
|
65
37
|
) {
|
|
66
|
-
return EQ.POST(equivalent, true, path,
|
|
38
|
+
return EQ.POST(equivalent, true, path, hint, dbc);
|
|
67
39
|
}
|
|
68
|
-
public static override INVARIANT(
|
|
69
|
-
equivalent,
|
|
70
|
-
path,
|
|
71
|
-
hint
|
|
72
|
-
);
|
|
73
|
-
public static override INVARIANT(
|
|
74
|
-
equivalent,
|
|
75
|
-
path,
|
|
76
|
-
);
|
|
77
40
|
|
|
78
|
-
/** See {@link
|
|
41
|
+
/** See {@link EQ.INVARIANT }. Always inverts equality check. */
|
|
42
|
+
// biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
|
|
79
43
|
public static INVARIANT(
|
|
80
|
-
equivalent,
|
|
81
|
-
|
|
82
|
-
path: string = undefined,
|
|
44
|
+
equivalent: any,
|
|
45
|
+
_invert = false,
|
|
46
|
+
path: string | undefined = undefined,
|
|
83
47
|
hint: string | undefined = undefined,
|
|
84
48
|
dbc: string | undefined = undefined,
|
|
85
49
|
) {
|
|
86
|
-
return EQ.INVARIANT(equivalent, true, path,
|
|
50
|
+
return EQ.INVARIANT(equivalent, true, path, hint, dbc);
|
|
87
51
|
}
|
|
88
|
-
/** See {@link
|
|
89
|
-
|
|
52
|
+
/** See {@link EQ.constructor }. */
|
|
53
|
+
// biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
|
|
54
|
+
constructor(public equivalent: any) {
|
|
90
55
|
super(equivalent, true);
|
|
91
56
|
}
|
|
92
57
|
}
|
package/src/DBC/EQ.ts
CHANGED
|
@@ -18,14 +18,14 @@ export class EQ extends DBC {
|
|
|
18
18
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
19
19
|
toCheck: any,
|
|
20
20
|
equivalent: object,
|
|
21
|
-
invert,
|
|
21
|
+
invert: boolean,
|
|
22
22
|
): boolean | string {
|
|
23
23
|
if (!invert && equivalent !== toCheck) {
|
|
24
|
-
return `Value has to
|
|
24
|
+
return `Value has to be equal to "${equivalent}"`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (invert && equivalent === toCheck) {
|
|
28
|
-
return `Value must not
|
|
28
|
+
return `Value must not be equal to "${equivalent}"`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return true;
|
|
@@ -51,19 +51,7 @@ export class EQ extends DBC {
|
|
|
51
51
|
methodName: string | symbol,
|
|
52
52
|
parameterIndex: number,
|
|
53
53
|
) => void {
|
|
54
|
-
return DBC.
|
|
55
|
-
(
|
|
56
|
-
value: object,
|
|
57
|
-
target: object,
|
|
58
|
-
methodName: string,
|
|
59
|
-
parameterIndex: number,
|
|
60
|
-
) => {
|
|
61
|
-
return EQ.checkAlgorithm(value, equivalent, invert);
|
|
62
|
-
},
|
|
63
|
-
dbc,
|
|
64
|
-
path,
|
|
65
|
-
hint
|
|
66
|
-
);
|
|
54
|
+
return DBC.createPRE(EQ.checkAlgorithm, [equivalent, invert], dbc, path, hint);
|
|
67
55
|
}
|
|
68
56
|
/**
|
|
69
57
|
* A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -87,14 +75,7 @@ export class EQ extends DBC {
|
|
|
87
75
|
propertyKey: string,
|
|
88
76
|
descriptor: PropertyDescriptor,
|
|
89
77
|
) => PropertyDescriptor {
|
|
90
|
-
return DBC.
|
|
91
|
-
(value: object, target: object, propertyKey: string) => {
|
|
92
|
-
return EQ.checkAlgorithm(value, equivalent, invert);
|
|
93
|
-
},
|
|
94
|
-
dbc,
|
|
95
|
-
path,
|
|
96
|
-
hint
|
|
97
|
-
);
|
|
78
|
+
return DBC.createPOST(EQ.checkAlgorithm, [equivalent, invert], dbc, path, hint);
|
|
98
79
|
}
|
|
99
80
|
/**
|
|
100
81
|
* A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -113,7 +94,7 @@ export class EQ extends DBC {
|
|
|
113
94
|
hint: string | undefined = undefined,
|
|
114
95
|
dbc: string | undefined = undefined,
|
|
115
96
|
) {
|
|
116
|
-
return DBC.
|
|
97
|
+
return DBC.createINVARIANT(EQ, [equivalent, invert], dbc, path, hint);
|
|
117
98
|
}
|
|
118
99
|
// #endregion Condition checking.
|
|
119
100
|
// #region Referenced Condition checking.
|
|
@@ -138,7 +119,7 @@ export class EQ extends DBC {
|
|
|
138
119
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link EQ }.
|
|
139
120
|
*
|
|
140
121
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link EQ }.*/
|
|
141
|
-
public static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
|
|
122
|
+
public static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
|
|
142
123
|
const result = EQ.checkAlgorithm(toCheck, equivalent, false);
|
|
143
124
|
|
|
144
125
|
if (result) {
|
package/src/DBC/HasAttribute.ts
CHANGED
|
@@ -19,16 +19,16 @@ export class HasAttribute extends DBC {
|
|
|
19
19
|
toCheckFor: string,
|
|
20
20
|
invert,
|
|
21
21
|
): boolean | string {
|
|
22
|
-
if(!(
|
|
23
|
-
return `The object to check for whether it has the attribute "${
|
|
22
|
+
if (!(toCheck instanceof HTMLElement)) {
|
|
23
|
+
return `The object to check for whether it has the attribute "${toCheckFor}" is not a HTMLElement. It is of type "${typeof toCheck}".`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
if (!invert && !(
|
|
27
|
-
return `Required Attribute "${
|
|
26
|
+
if (!invert && !(toCheck as HTMLElement).hasAttribute(toCheckFor)) {
|
|
27
|
+
return `Required Attribute "${toCheckFor}" is not set.`;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (invert && (
|
|
31
|
-
return `Forbidden Attribute "${
|
|
30
|
+
if (invert && (toCheck as HTMLElement).hasAttribute(toCheckFor)) {
|
|
31
|
+
return `Forbidden Attribute "${toCheckFor}" is set.`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return true;
|
|
@@ -52,18 +52,7 @@ export class HasAttribute extends DBC {
|
|
|
52
52
|
methodName: string | symbol,
|
|
53
53
|
parameterIndex: number,
|
|
54
54
|
) => void {
|
|
55
|
-
return DBC.
|
|
56
|
-
(
|
|
57
|
-
value: object,
|
|
58
|
-
target: object,
|
|
59
|
-
methodName: string,
|
|
60
|
-
parameterIndex: number,
|
|
61
|
-
) => {
|
|
62
|
-
return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
|
|
63
|
-
},
|
|
64
|
-
dbc,
|
|
65
|
-
path,
|
|
66
|
-
);
|
|
55
|
+
return DBC.createPRE(HasAttribute.checkAlgorithm, [toCheckFor, invert], dbc, path);
|
|
67
56
|
}
|
|
68
57
|
/**
|
|
69
58
|
* A method-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
@@ -84,13 +73,7 @@ export class HasAttribute extends DBC {
|
|
|
84
73
|
propertyKey: string,
|
|
85
74
|
descriptor: PropertyDescriptor,
|
|
86
75
|
) => PropertyDescriptor {
|
|
87
|
-
return DBC.
|
|
88
|
-
(value: object, target: object, propertyKey: string) => {
|
|
89
|
-
return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
|
|
90
|
-
},
|
|
91
|
-
dbc,
|
|
92
|
-
path,
|
|
93
|
-
);
|
|
76
|
+
return DBC.createPOST(HasAttribute.checkAlgorithm, [toCheckFor, invert], dbc, path);
|
|
94
77
|
}
|
|
95
78
|
/**
|
|
96
79
|
* A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
@@ -107,7 +90,7 @@ export class HasAttribute extends DBC {
|
|
|
107
90
|
path: string | undefined = undefined,
|
|
108
91
|
dbc = "WaXCode.DBC",
|
|
109
92
|
) {
|
|
110
|
-
return DBC.
|
|
93
|
+
return DBC.createINVARIANT(HasAttribute, [toCheckFor, invert], dbc, path);
|
|
111
94
|
}
|
|
112
95
|
/**
|
|
113
96
|
* A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
package/src/DBC/IF.ts
CHANGED
|
@@ -22,14 +22,14 @@ export class IF extends DBC {
|
|
|
22
22
|
inCase: {
|
|
23
23
|
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
24
24
|
},
|
|
25
|
-
invert,
|
|
25
|
+
invert: boolean = false,
|
|
26
26
|
): boolean | string {
|
|
27
|
-
if (invert &&
|
|
28
|
-
return `In case that the value
|
|
27
|
+
if (invert && condition.check(toCheck) !== true && inCase.check(toCheck) !== true) {
|
|
28
|
+
return `In case that the value does not comply to the condition, it also has to comply to the required contract`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (!invert && condition.check(toCheck) &&
|
|
32
|
-
return `In case that the value
|
|
31
|
+
if (!invert && condition.check(toCheck) === true && inCase.check(toCheck) !== true) {
|
|
32
|
+
return `In case that the value complies to the condition, it has to comply to the required contract`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return true;
|
|
@@ -56,19 +56,7 @@ export class IF extends DBC {
|
|
|
56
56
|
methodName: string | symbol,
|
|
57
57
|
parameterIndex: number,
|
|
58
58
|
) => void {
|
|
59
|
-
return DBC.
|
|
60
|
-
(
|
|
61
|
-
value: object,
|
|
62
|
-
target: object,
|
|
63
|
-
methodName: string,
|
|
64
|
-
parameterIndex: number,
|
|
65
|
-
) => {
|
|
66
|
-
return IF.checkAlgorithm(value, condition, inCase, invert);
|
|
67
|
-
},
|
|
68
|
-
dbc,
|
|
69
|
-
path,
|
|
70
|
-
hint
|
|
71
|
-
);
|
|
59
|
+
return DBC.createPRE(IF.checkAlgorithm, [condition, inCase, invert], dbc, path, hint);
|
|
72
60
|
}
|
|
73
61
|
/**
|
|
74
62
|
* A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -92,14 +80,7 @@ export class IF extends DBC {
|
|
|
92
80
|
propertyKey: string,
|
|
93
81
|
descriptor: PropertyDescriptor,
|
|
94
82
|
) => PropertyDescriptor {
|
|
95
|
-
return DBC.
|
|
96
|
-
(value: object, target: object, propertyKey: string) => {
|
|
97
|
-
return IF.checkAlgorithm(value, condition, inCase, invert);
|
|
98
|
-
},
|
|
99
|
-
dbc,
|
|
100
|
-
path,
|
|
101
|
-
hint
|
|
102
|
-
);
|
|
83
|
+
return DBC.createPOST(IF.checkAlgorithm, [condition, inCase, invert], dbc, path, hint);
|
|
103
84
|
}
|
|
104
85
|
/**
|
|
105
86
|
* A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -119,7 +100,7 @@ export class IF extends DBC {
|
|
|
119
100
|
hint: string | undefined = undefined,
|
|
120
101
|
dbc: string | undefined = undefined,
|
|
121
102
|
) {
|
|
122
|
-
return DBC.
|
|
103
|
+
return DBC.createINVARIANT(IF, [condition, inCase, invert], dbc, path, hint);
|
|
123
104
|
}
|
|
124
105
|
// #endregion Condition checking.
|
|
125
106
|
// #region Referenced Condition checking.
|
package/src/DBC/INSTANCE.ts
CHANGED
|
@@ -47,19 +47,8 @@ export class INSTANCE extends DBC {
|
|
|
47
47
|
methodName: string | symbol,
|
|
48
48
|
parameterIndex: number,
|
|
49
49
|
) => void {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
value: object,
|
|
53
|
-
target: object,
|
|
54
|
-
methodName: string,
|
|
55
|
-
parameterIndex: number,
|
|
56
|
-
) => {
|
|
57
|
-
return Array.isArray(reference) ? INSTANCE.checkAlgorithm(value, ...reference) : INSTANCE.checkAlgorithm(value, reference);
|
|
58
|
-
},
|
|
59
|
-
dbc,
|
|
60
|
-
path,
|
|
61
|
-
hint
|
|
62
|
-
);
|
|
50
|
+
const refs = Array.isArray(reference) ? reference : [reference];
|
|
51
|
+
return DBC.createPRE(INSTANCE.checkAlgorithm, refs, dbc, path, hint);
|
|
63
52
|
}
|
|
64
53
|
/**
|
|
65
54
|
* A method-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -81,14 +70,8 @@ export class INSTANCE extends DBC {
|
|
|
81
70
|
propertyKey: string,
|
|
82
71
|
descriptor: PropertyDescriptor,
|
|
83
72
|
) => PropertyDescriptor {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return Array.isArray(reference) ? INSTANCE.checkAlgorithm(value, ...reference) : INSTANCE.checkAlgorithm(value, reference);
|
|
87
|
-
},
|
|
88
|
-
dbc,
|
|
89
|
-
path,
|
|
90
|
-
hint
|
|
91
|
-
);
|
|
73
|
+
const refs = Array.isArray(reference) ? reference : [reference];
|
|
74
|
+
return DBC.createPOST(INSTANCE.checkAlgorithm, refs, dbc, path, hint);
|
|
92
75
|
}
|
|
93
76
|
/**
|
|
94
77
|
* A field-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -106,7 +89,7 @@ export class INSTANCE extends DBC {
|
|
|
106
89
|
hint: string | undefined = undefined,
|
|
107
90
|
dbc: string | undefined = undefined,
|
|
108
91
|
) {
|
|
109
|
-
return DBC.
|
|
92
|
+
return DBC.createINVARIANT(INSTANCE, [reference], dbc, path, hint);
|
|
110
93
|
}
|
|
111
94
|
// #endregion Condition checking.
|
|
112
95
|
// #region Referenced Condition checking.
|
package/src/DBC/JSON.OP.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class JSON_OP extends DBC {
|
|
|
23
23
|
necessaryProperties: Array<{ name: string; type: string }>,
|
|
24
24
|
checkElements,
|
|
25
25
|
): boolean | string {
|
|
26
|
-
if (toCheck === undefined || null) {
|
|
26
|
+
if (toCheck === undefined || toCheck === null) {
|
|
27
27
|
return `[ UNDEFINED or NULL received instead of object with following properties: ${JSON.stringify(necessaryProperties)} ]`;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -71,22 +71,7 @@ export class JSON_OP extends DBC {
|
|
|
71
71
|
methodName: string | symbol,
|
|
72
72
|
parameterIndex: number,
|
|
73
73
|
) => void {
|
|
74
|
-
return DBC.
|
|
75
|
-
(
|
|
76
|
-
value: string,
|
|
77
|
-
target: object,
|
|
78
|
-
methodName: string,
|
|
79
|
-
parameterIndex: number,
|
|
80
|
-
) => {
|
|
81
|
-
return JSON_OP.checkAlgorithm(
|
|
82
|
-
value,
|
|
83
|
-
necessaryProperties,
|
|
84
|
-
checkElements,
|
|
85
|
-
);
|
|
86
|
-
},
|
|
87
|
-
dbc,
|
|
88
|
-
path,
|
|
89
|
-
);
|
|
74
|
+
return DBC.createPRE(JSON_OP.checkAlgorithm, [necessaryProperties, checkElements], dbc, path);
|
|
90
75
|
}
|
|
91
76
|
/**
|
|
92
77
|
* A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -107,18 +92,7 @@ export class JSON_OP extends DBC {
|
|
|
107
92
|
propertyKey: string,
|
|
108
93
|
descriptor: PropertyDescriptor,
|
|
109
94
|
) => PropertyDescriptor {
|
|
110
|
-
return DBC.
|
|
111
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
112
|
-
(value: any, target: object, propertyKey: string) => {
|
|
113
|
-
return JSON_OP.checkAlgorithm(
|
|
114
|
-
value,
|
|
115
|
-
necessaryProperties,
|
|
116
|
-
checkElements,
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
dbc,
|
|
120
|
-
path,
|
|
121
|
-
);
|
|
95
|
+
return DBC.createPOST(JSON_OP.checkAlgorithm, [necessaryProperties, checkElements], dbc, path);
|
|
122
96
|
}
|
|
123
97
|
/**
|
|
124
98
|
* A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -135,11 +109,7 @@ export class JSON_OP extends DBC {
|
|
|
135
109
|
path: string | undefined = undefined,
|
|
136
110
|
dbc = "WaXCode.DBC",
|
|
137
111
|
) {
|
|
138
|
-
return DBC.
|
|
139
|
-
[new JSON_OP(necessaryProperties, checkElements)],
|
|
140
|
-
path,
|
|
141
|
-
dbc,
|
|
142
|
-
);
|
|
112
|
+
return DBC.createINVARIANT(JSON_OP, [necessaryProperties, checkElements], dbc, path);
|
|
143
113
|
}
|
|
144
114
|
// #endregion Condition checking.
|
|
145
115
|
// #region Referenced Condition checking.
|
package/src/DBC/JSON.Parse.ts
CHANGED
|
@@ -52,19 +52,7 @@ export class JSON_Parse extends DBC {
|
|
|
52
52
|
methodName: string | symbol,
|
|
53
53
|
parameterIndex: number,
|
|
54
54
|
) => void {
|
|
55
|
-
return DBC.
|
|
56
|
-
(
|
|
57
|
-
value: string,
|
|
58
|
-
target: object,
|
|
59
|
-
methodName: string,
|
|
60
|
-
parameterIndex: number,
|
|
61
|
-
) => {
|
|
62
|
-
return JSON_Parse.checkAlgorithm(value, receptor);
|
|
63
|
-
},
|
|
64
|
-
dbc,
|
|
65
|
-
path,
|
|
66
|
-
hint
|
|
67
|
-
);
|
|
55
|
+
return DBC.createPRE(JSON_Parse.checkAlgorithm, [receptor], dbc, path, hint);
|
|
68
56
|
}
|
|
69
57
|
/**
|
|
70
58
|
* A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -85,15 +73,7 @@ export class JSON_Parse extends DBC {
|
|
|
85
73
|
propertyKey: string,
|
|
86
74
|
descriptor: PropertyDescriptor,
|
|
87
75
|
) => PropertyDescriptor {
|
|
88
|
-
return DBC.
|
|
89
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
90
|
-
(value: any, target: object, propertyKey: string) => {
|
|
91
|
-
return JSON_Parse.checkAlgorithm(value, receptor);
|
|
92
|
-
},
|
|
93
|
-
dbc,
|
|
94
|
-
path,
|
|
95
|
-
hint
|
|
96
|
-
);
|
|
76
|
+
return DBC.createPOST(JSON_Parse.checkAlgorithm, [receptor], dbc, path, hint);
|
|
97
77
|
}
|
|
98
78
|
/**
|
|
99
79
|
* A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
@@ -110,7 +90,7 @@ export class JSON_Parse extends DBC {
|
|
|
110
90
|
hint: string | undefined = undefined,
|
|
111
91
|
dbc: string | undefined = undefined,
|
|
112
92
|
) {
|
|
113
|
-
return DBC.
|
|
93
|
+
return DBC.createINVARIANT(JSON_Parse, [receptor], dbc, path, hint);
|
|
114
94
|
}
|
|
115
95
|
// #endregion Condition checking.
|
|
116
96
|
// #region Referenced Condition checking.
|
|
@@ -125,14 +105,14 @@ export class JSON_Parse extends DBC {
|
|
|
125
105
|
* @returns See {@link JSON_Parse.checkAlgorithm}. */
|
|
126
106
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
127
107
|
public check(toCheck: any) {
|
|
128
|
-
return JSON_Parse.checkAlgorithm(toCheck, this.receptor);
|
|
108
|
+
return JSON_Parse.checkAlgorithm(toCheck, this.receptor as (json: object) => void);
|
|
129
109
|
}
|
|
130
110
|
/**
|
|
131
111
|
* Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
|
|
132
112
|
*
|
|
133
113
|
* @param necessaryProperties See {@link JSON_Parse.check }.
|
|
134
114
|
* @param checkElements See {@link JSON_Parse.check }. */
|
|
135
|
-
public constructor(public receptor: (json: object) => void = undefined) {
|
|
115
|
+
public constructor(public receptor: ((json: object) => void) | undefined = undefined) {
|
|
136
116
|
super();
|
|
137
117
|
}
|
|
138
118
|
// #endregion Referenced Condition checking.
|
package/src/DBC/OR.ts
CHANGED
|
@@ -74,17 +74,10 @@ export class OR extends DBC {
|
|
|
74
74
|
parameterIndex: number,
|
|
75
75
|
) => void {
|
|
76
76
|
return DBC.decPrecondition(
|
|
77
|
-
(
|
|
78
|
-
value: object,
|
|
79
|
-
target: object,
|
|
80
|
-
methodName: string,
|
|
81
|
-
parameterIndex: number,
|
|
82
|
-
) => {
|
|
83
|
-
return OR.checkAlgorithm(conditions, value);
|
|
84
|
-
},
|
|
77
|
+
(value) => OR.checkAlgorithm(conditions, value),
|
|
85
78
|
dbc,
|
|
86
79
|
path,
|
|
87
|
-
hint
|
|
80
|
+
hint,
|
|
88
81
|
);
|
|
89
82
|
}
|
|
90
83
|
/**
|
|
@@ -111,12 +104,10 @@ export class OR extends DBC {
|
|
|
111
104
|
descriptor: PropertyDescriptor,
|
|
112
105
|
) => PropertyDescriptor {
|
|
113
106
|
return DBC.decPostcondition(
|
|
114
|
-
(value
|
|
115
|
-
return OR.checkAlgorithm(conditions, value);
|
|
116
|
-
},
|
|
107
|
+
(value) => OR.checkAlgorithm(conditions, value),
|
|
117
108
|
dbc,
|
|
118
109
|
path,
|
|
119
|
-
hint
|
|
110
|
+
hint,
|
|
120
111
|
);
|
|
121
112
|
}
|
|
122
113
|
/**
|
|
@@ -137,7 +128,7 @@ export class OR extends DBC {
|
|
|
137
128
|
hint: string | undefined = undefined,
|
|
138
129
|
dbc: string | undefined = undefined,
|
|
139
130
|
) {
|
|
140
|
-
return DBC.
|
|
131
|
+
return DBC.createINVARIANT(OR, [conditions], dbc, path, hint);
|
|
141
132
|
}
|
|
142
133
|
// #endregion Condition checking.
|
|
143
134
|
// #region Referenced Condition checking.
|