xdbc 1.0.217 → 1.0.219
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/.gitattributes +16 -8
- package/.vscode/settings.json +3 -3
- package/.vscode/tasks.json +23 -23
- package/ASSESSMENT.md +249 -0
- package/README.md +538 -408
- package/__tests__/DBC/AE.test.ts +62 -62
- package/__tests__/DBC/ARRAY.test.ts +91 -91
- package/__tests__/DBC/DEFINED.test.ts +53 -53
- package/__tests__/DBC/DOM.test.ts +786 -0
- package/__tests__/DBC/Decorators.test.ts +367 -367
- package/__tests__/DBC/EQ.test.ts +13 -13
- package/__tests__/DBC/GREATER.test.ts +31 -31
- package/__tests__/DBC/HasAttribute.test.ts +60 -60
- package/__tests__/DBC/IF.test.ts +62 -62
- package/__tests__/DBC/INSTANCE.test.ts +13 -13
- package/__tests__/DBC/JSON.OP.test.ts +47 -47
- package/__tests__/DBC/JSON.Parse.test.ts +17 -17
- package/__tests__/DBC/OR.test.ts +14 -14
- package/__tests__/DBC/PLAIN_OBJECT.test.ts +109 -109
- package/__tests__/DBC/REGEX.test.ts +17 -17
- package/__tests__/DBC/TYPE.test.ts +13 -13
- package/__tests__/DBC/UNDEFINED.test.ts +45 -45
- package/__tests__/DBC/ZOD.test.ts +54 -54
- package/__tests__/DBC/onInfringement.test.ts +262 -0
- package/biome.json +45 -40
- package/dist/DBC/AE.js +172 -0
- package/dist/DBC/ARR/PLAIN_OBJECT.d.ts +0 -3
- package/dist/DBC/ARR/PLAIN_OBJECT.js +95 -0
- package/dist/DBC/ARRAY.d.ts +0 -3
- package/dist/DBC/ARRAY.js +90 -0
- package/dist/DBC/COMPARISON/GREATER.js +21 -0
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON/LESS.js +21 -0
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON.js +98 -0
- package/dist/DBC/DEFINED.js +87 -0
- package/dist/DBC/DOM.d.ts +123 -0
- package/dist/DBC/DOM.js +362 -0
- package/dist/DBC/EQ/DIFFERENT.js +34 -0
- package/dist/DBC/EQ.js +101 -0
- package/dist/DBC/GREATER.js +99 -0
- package/dist/DBC/HasAttribute.js +101 -0
- package/dist/DBC/IF.js +96 -0
- package/dist/DBC/INSTANCE.js +122 -0
- package/dist/DBC/JSON.OP.js +120 -0
- package/dist/DBC/JSON.Parse.js +104 -0
- package/dist/DBC/OR.js +125 -0
- package/dist/DBC/REGEX.js +136 -0
- package/dist/DBC/TYPE.js +112 -0
- package/dist/DBC/UNDEFINED.js +87 -0
- package/dist/DBC/ZOD.js +99 -0
- package/dist/DBC.d.ts +18 -4
- package/dist/DBC.js +645 -0
- package/dist/Demo.d.ts +10 -0
- package/dist/Demo.js +713 -0
- package/dist/Test.html +18 -0
- package/dist/bundle.js +6140 -405
- package/dist/index.d.ts +22 -0
- package/dist/index.html +18 -0
- package/dist/index.js +22 -0
- package/docs/assets/highlight.css +22 -22
- package/docs/assets/icons.js +17 -17
- package/docs/assets/main.js +60 -60
- package/docs/assets/style.css +1640 -1640
- package/docs/classes/DBC.DBC.html +98 -98
- package/docs/classes/DBC_AE.AE.html +160 -160
- package/docs/classes/DBC_EQ.EQ.html +131 -131
- package/docs/classes/DBC_GREATER.GREATER.html +139 -139
- package/docs/classes/DBC_INSTANCE.INSTANCE.html +130 -130
- package/docs/classes/DBC_JSON.OP.JSON_OP.html +138 -138
- package/docs/classes/DBC_JSON.Parse.JSON_Parse.html +129 -129
- package/docs/classes/DBC_OR.OR.html +137 -137
- package/docs/classes/DBC_REGEX.REGEX.html +136 -136
- package/docs/classes/DBC_TYPE.TYPE.html +130 -130
- package/docs/classes/Demo.Demo.html +14 -14
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +1 -1
- package/docs/modules/DBC.html +1 -1
- package/docs/modules/DBC_AE.html +1 -1
- package/docs/modules/DBC_EQ.html +1 -1
- package/docs/modules/DBC_GREATER.html +1 -1
- package/docs/modules/DBC_INSTANCE.html +1 -1
- package/docs/modules/DBC_JSON.OP.html +1 -1
- package/docs/modules/DBC_JSON.Parse.html +1 -1
- package/docs/modules/DBC_OR.html +1 -1
- package/docs/modules/DBC_REGEX.html +1 -1
- package/docs/modules/DBC_TYPE.html +1 -1
- package/docs/modules/Demo.html +1 -1
- package/jest.config.js +32 -32
- package/package.json +71 -55
- package/src/DBC/AE.ts +269 -288
- package/src/DBC/ARR/PLAIN_OBJECT.ts +122 -133
- package/src/DBC/ARRAY.ts +117 -127
- package/src/DBC/COMPARISON/GREATER.ts +41 -46
- package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +41 -45
- package/src/DBC/COMPARISON/LESS.ts +41 -45
- package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +41 -45
- package/src/DBC/COMPARISON.ts +149 -159
- package/src/DBC/DEFINED.ts +117 -122
- package/src/DBC/DOM.ts +453 -0
- package/src/DBC/EQ/DIFFERENT.ts +51 -57
- package/src/DBC/EQ.ts +154 -163
- package/src/DBC/HasAttribute.ts +149 -154
- package/src/DBC/IF.ts +173 -179
- package/src/DBC/INSTANCE.ts +168 -171
- package/src/DBC/JSON.OP.ts +178 -186
- package/src/DBC/JSON.Parse.ts +150 -157
- package/src/DBC/OR.ts +183 -187
- package/src/DBC/REGEX.ts +195 -196
- package/src/DBC/TYPE.ts +142 -149
- package/src/DBC/UNDEFINED.ts +115 -117
- package/src/DBC/ZOD.ts +130 -135
- package/src/DBC.ts +902 -904
- package/src/Demo.ts +537 -404
- package/src/index.ts +22 -0
- package/tsconfig.json +18 -18
- package/tsconfig.test.json +7 -7
- package/typedoc.json +16 -16
- package/webpack.config.js +27 -27
- package/Assessment.md +0 -507
|
@@ -1,133 +1,122 @@
|
|
|
1
|
-
import { DBC } from "../../DBC";
|
|
2
|
-
import { ARRAY } from "../ARRAY";
|
|
3
|
-
/**
|
|
4
|
-
* A {@link DBC } defining that a value must be a plain object — i.e. `typeof value === "object"`,
|
|
5
|
-
* not `null`, and not an array.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
9
|
-
export class PLAIN_OBJECT extends ARRAY {
|
|
10
|
-
/**
|
|
11
|
-
* Checks if the value **toCheck** is a plain object (non-null, non-array object).
|
|
12
|
-
*
|
|
13
|
-
* @param toCheck The value to check.
|
|
14
|
-
*
|
|
15
|
-
* @returns TRUE if the value **toCheck** is a plain object, otherwise a string describing the infringement. */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
|
|
124
|
-
dbc,
|
|
125
|
-
);
|
|
126
|
-
return toCheck as CANDIDATE;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Creates this {@link PLAIN_OBJECT } instance. No parameters needed — the check is always the same. */
|
|
130
|
-
public constructor() {
|
|
131
|
-
super();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
1
|
+
import { DBC } from "../../DBC";
|
|
2
|
+
import { ARRAY } from "../ARRAY";
|
|
3
|
+
/**
|
|
4
|
+
* A {@link DBC } defining that a value must be a plain object — i.e. `typeof value === "object"`,
|
|
5
|
+
* not `null`, and not an array.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
9
|
+
export class PLAIN_OBJECT extends ARRAY {
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the value **toCheck** is a plain object (non-null, non-array object).
|
|
12
|
+
*
|
|
13
|
+
* @param toCheck The value to check.
|
|
14
|
+
*
|
|
15
|
+
* @returns TRUE if the value **toCheck** is a plain object, otherwise a string describing the infringement. */
|
|
16
|
+
public static checkAlgorithm(toCheck: any): boolean | string {
|
|
17
|
+
if (toCheck === undefined || toCheck === null) return true;
|
|
18
|
+
if (typeof toCheck !== "object") {
|
|
19
|
+
return `Value has to be a PLAIN_OBJECT but is of type "${typeof toCheck}"`;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(toCheck)) {
|
|
22
|
+
return "Value has to be a PLAIN_OBJECT but is an ARRAY";
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A parameter-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
28
|
+
* by the tagged parameter.
|
|
29
|
+
*
|
|
30
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
31
|
+
* @param hint See {@link DBC.decPrecondition }.
|
|
32
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
33
|
+
*
|
|
34
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
35
|
+
public static PRE(
|
|
36
|
+
path: string | undefined = undefined,
|
|
37
|
+
hint: string | undefined = undefined,
|
|
38
|
+
dbc: string | undefined = undefined,
|
|
39
|
+
): (
|
|
40
|
+
target: object,
|
|
41
|
+
methodName: string | symbol | undefined,
|
|
42
|
+
parameterIndex: number,
|
|
43
|
+
) => void {
|
|
44
|
+
return DBC.createPRE(PLAIN_OBJECT.checkAlgorithm, [], dbc, path, hint);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A method-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
48
|
+
* by the tagged method's returnvalue.
|
|
49
|
+
*
|
|
50
|
+
* @param path See {@link DBC.decPostcondition }.
|
|
51
|
+
* @param hint See {@link DBC.decPostcondition }.
|
|
52
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
53
|
+
*
|
|
54
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
55
|
+
public static POST(
|
|
56
|
+
path: string | undefined = undefined,
|
|
57
|
+
hint: string | undefined = undefined,
|
|
58
|
+
dbc: string | undefined = undefined,
|
|
59
|
+
): (
|
|
60
|
+
target: object,
|
|
61
|
+
propertyKey: string,
|
|
62
|
+
descriptor: PropertyDescriptor,
|
|
63
|
+
) => PropertyDescriptor {
|
|
64
|
+
return DBC.createPOST(PLAIN_OBJECT.checkAlgorithm, [], dbc, path, hint);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A field-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
68
|
+
* by the tagged field.
|
|
69
|
+
*
|
|
70
|
+
* @param path See {@link DBC.decInvariant }.
|
|
71
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
72
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
73
|
+
*
|
|
74
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
75
|
+
public static INVARIANT(
|
|
76
|
+
path: string | undefined = undefined,
|
|
77
|
+
hint: string | undefined = undefined,
|
|
78
|
+
dbc: string | undefined = undefined,
|
|
79
|
+
) {
|
|
80
|
+
return DBC.createINVARIANT(PLAIN_OBJECT, [], dbc, path, hint);
|
|
81
|
+
}
|
|
82
|
+
// #endregion Condition checking.
|
|
83
|
+
// #region Referenced Condition checking.
|
|
84
|
+
//
|
|
85
|
+
// For usage in dynamic scenarios (like with AE-DBC).
|
|
86
|
+
//
|
|
87
|
+
/**
|
|
88
|
+
* Invokes the {@link PLAIN_OBJECT.checkAlgorithm } passing the value **toCheck**.
|
|
89
|
+
*
|
|
90
|
+
* @param toCheck See {@link PLAIN_OBJECT.checkAlgorithm }.
|
|
91
|
+
*
|
|
92
|
+
* @returns See {@link PLAIN_OBJECT.checkAlgorithm}. */
|
|
93
|
+
public check(toCheck: any) {
|
|
94
|
+
return PLAIN_OBJECT.checkAlgorithm(toCheck);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Invokes the {@link PLAIN_OBJECT.checkAlgorithm } passing the value **toCheck**.
|
|
98
|
+
*
|
|
99
|
+
* @param toCheck See {@link PLAIN_OBJECT.checkAlgorithm }.
|
|
100
|
+
* @param hint An optional {@link string } providing extra information in case of an infringement.
|
|
101
|
+
* @param id A {@link string } identifying this {@link PLAIN_OBJECT } via the {@link DBC.Infringement }-Message.
|
|
102
|
+
*
|
|
103
|
+
* @returns The **CANDIDATE** **toCheck** if this {@link PLAIN_OBJECT } is fulfilled.
|
|
104
|
+
*
|
|
105
|
+
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link PLAIN_OBJECT }. */
|
|
106
|
+
public static tsCheck<CANDIDATE extends object = object>(
|
|
107
|
+
toCheck: CANDIDATE | undefined | null,
|
|
108
|
+
hint: string | undefined = undefined,
|
|
109
|
+
id: string | undefined = undefined,
|
|
110
|
+
dbc: string | undefined = undefined,
|
|
111
|
+
): CANDIDATE {
|
|
112
|
+
const result = PLAIN_OBJECT.checkAlgorithm(toCheck);
|
|
113
|
+
if (result === true) {
|
|
114
|
+
return toCheck as CANDIDATE;
|
|
115
|
+
}
|
|
116
|
+
DBC.reportTsCheckInfringement(
|
|
117
|
+
`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
|
|
118
|
+
dbc,
|
|
119
|
+
);
|
|
120
|
+
return toCheck as CANDIDATE;
|
|
121
|
+
}
|
|
122
|
+
}
|
package/src/DBC/ARRAY.ts
CHANGED
|
@@ -1,127 +1,117 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } defining that a value must be an array.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
-
export class ARRAY extends DBC {
|
|
8
|
-
/**
|
|
9
|
-
* Checks if the value **toCheck** is an array.
|
|
10
|
-
*
|
|
11
|
-
* @param toCheck The value to check.
|
|
12
|
-
*
|
|
13
|
-
* @returns TRUE if the value **toCheck** is an array, otherwise a string describing the infringement. */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (toCheck
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @
|
|
99
|
-
*
|
|
100
|
-
* @
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
dbc,
|
|
119
|
-
);
|
|
120
|
-
return toCheck as CANDIDATE;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Creates this {@link ARRAY } instance. No parameters needed — the check is always {@link Array.isArray }. */
|
|
124
|
-
public constructor() {
|
|
125
|
-
super();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that a value must be an array.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
+
export class ARRAY extends DBC {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the value **toCheck** is an array.
|
|
10
|
+
*
|
|
11
|
+
* @param toCheck The value to check.
|
|
12
|
+
*
|
|
13
|
+
* @returns TRUE if the value **toCheck** is an array, otherwise a string describing the infringement. */
|
|
14
|
+
public static checkAlgorithm(toCheck: any): boolean | string {
|
|
15
|
+
if (toCheck === undefined || toCheck === null) return true;
|
|
16
|
+
if (!Array.isArray(toCheck)) {
|
|
17
|
+
return `Value has to be an ARRAY but is of type "${typeof toCheck}"`;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A parameter-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
23
|
+
* by the tagged parameter.
|
|
24
|
+
*
|
|
25
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
26
|
+
* @param hint See {@link DBC.decPrecondition }.
|
|
27
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
28
|
+
*
|
|
29
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
30
|
+
public static PRE(
|
|
31
|
+
path: string | undefined = undefined,
|
|
32
|
+
hint: string | undefined = undefined,
|
|
33
|
+
dbc: string | undefined = undefined,
|
|
34
|
+
): (
|
|
35
|
+
target: object,
|
|
36
|
+
methodName: string | symbol | undefined,
|
|
37
|
+
parameterIndex: number,
|
|
38
|
+
) => void {
|
|
39
|
+
return DBC.createPRE(ARRAY.checkAlgorithm, [], dbc, path, hint);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A method-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
43
|
+
* by the tagged method's returnvalue.
|
|
44
|
+
*
|
|
45
|
+
* @param path See {@link DBC.decPostcondition }.
|
|
46
|
+
* @param hint See {@link DBC.decPostcondition }.
|
|
47
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
48
|
+
*
|
|
49
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
50
|
+
public static POST(
|
|
51
|
+
path: string | undefined = undefined,
|
|
52
|
+
hint: string | undefined = undefined,
|
|
53
|
+
dbc: string | undefined = undefined,
|
|
54
|
+
): (
|
|
55
|
+
target: object,
|
|
56
|
+
propertyKey: string,
|
|
57
|
+
descriptor: PropertyDescriptor,
|
|
58
|
+
) => PropertyDescriptor {
|
|
59
|
+
return DBC.createPOST(ARRAY.checkAlgorithm, [], dbc, path, hint);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A field-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
63
|
+
* by the tagged field.
|
|
64
|
+
*
|
|
65
|
+
* @param path See {@link DBC.decInvariant }.
|
|
66
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
67
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
68
|
+
*
|
|
69
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
70
|
+
public static INVARIANT(
|
|
71
|
+
path: string | undefined = undefined,
|
|
72
|
+
hint: string | undefined = undefined,
|
|
73
|
+
dbc: string | undefined = undefined,
|
|
74
|
+
) {
|
|
75
|
+
return DBC.createINVARIANT(ARRAY, [], dbc, path, hint);
|
|
76
|
+
}
|
|
77
|
+
// #endregion Condition checking.
|
|
78
|
+
// #region Referenced Condition checking.
|
|
79
|
+
//
|
|
80
|
+
// For usage in dynamic scenarios (like with AE-DBC).
|
|
81
|
+
//
|
|
82
|
+
/**
|
|
83
|
+
* Invokes the {@link ARRAY.checkAlgorithm } passing the value **toCheck**.
|
|
84
|
+
*
|
|
85
|
+
* @param toCheck See {@link ARRAY.checkAlgorithm }.
|
|
86
|
+
*
|
|
87
|
+
* @returns See {@link ARRAY.checkAlgorithm}. */
|
|
88
|
+
public check(toCheck: any) {
|
|
89
|
+
return ARRAY.checkAlgorithm(toCheck);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Invokes the {@link ARRAY.checkAlgorithm } passing the value **toCheck**.
|
|
93
|
+
*
|
|
94
|
+
* @param toCheck See {@link ARRAY.checkAlgorithm }.
|
|
95
|
+
* @param hint An optional {@link string } providing extra information in case of an infringement.
|
|
96
|
+
* @param id A {@link string } identifying this {@link ARRAY } via the {@link DBC.Infringement }-Message.
|
|
97
|
+
*
|
|
98
|
+
* @returns The **CANDIDATE** **toCheck** if this {@link ARRAY } is fulfilled.
|
|
99
|
+
*
|
|
100
|
+
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link ARRAY }. */
|
|
101
|
+
public static tsCheck<CANDIDATE extends unknown[] = unknown[]>(
|
|
102
|
+
toCheck: CANDIDATE | undefined | null,
|
|
103
|
+
hint: string | undefined = undefined,
|
|
104
|
+
id: string | undefined = undefined,
|
|
105
|
+
dbc: string | undefined = undefined,
|
|
106
|
+
): CANDIDATE {
|
|
107
|
+
const result = ARRAY.checkAlgorithm(toCheck);
|
|
108
|
+
if (result === true) {
|
|
109
|
+
return toCheck as CANDIDATE;
|
|
110
|
+
}
|
|
111
|
+
DBC.reportTsCheckInfringement(
|
|
112
|
+
`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
|
|
113
|
+
dbc,
|
|
114
|
+
);
|
|
115
|
+
return toCheck as CANDIDATE;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
import { COMPARISON } from "../COMPARISON";
|
|
2
|
-
/** See {@link COMPARISON }. */
|
|
3
|
-
export class GREATER extends COMPARISON {
|
|
4
|
-
/** See {@link COMPARISON.PRE }. */
|
|
5
|
-
public static override PRE(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
) {
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
|
|
43
|
-
constructor(public override equivalent: any) {
|
|
44
|
-
super(equivalent, false, false);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { COMPARISON } from "../COMPARISON";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export class GREATER extends COMPARISON {
|
|
4
|
+
/** See {@link COMPARISON.PRE }. */
|
|
5
|
+
public static override PRE(
|
|
6
|
+
equivalent: any,
|
|
7
|
+
equalityPermitted = false,
|
|
8
|
+
invert = false,
|
|
9
|
+
path: string | undefined = undefined,
|
|
10
|
+
hint: string | undefined = undefined,
|
|
11
|
+
dbc: string | undefined = undefined,
|
|
12
|
+
) {
|
|
13
|
+
return COMPARISON.PRE(equivalent, false, false, path, hint, dbc);
|
|
14
|
+
}
|
|
15
|
+
/** See {@link COMPARISON.POST }. */
|
|
16
|
+
public static override POST(
|
|
17
|
+
equivalent: any,
|
|
18
|
+
equalityPermitted = false,
|
|
19
|
+
invert = false,
|
|
20
|
+
path: string | undefined = undefined,
|
|
21
|
+
hint: string | undefined = undefined,
|
|
22
|
+
dbc: string | undefined = undefined,
|
|
23
|
+
) {
|
|
24
|
+
return COMPARISON.POST(equivalent, false, false, path, hint, dbc);
|
|
25
|
+
}
|
|
26
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
27
|
+
public static override INVARIANT(
|
|
28
|
+
equivalent: any,
|
|
29
|
+
equalityPermitted = false,
|
|
30
|
+
invert = false,
|
|
31
|
+
path: string | undefined = undefined,
|
|
32
|
+
hint: string | undefined = undefined,
|
|
33
|
+
dbc: string | undefined = undefined,
|
|
34
|
+
) {
|
|
35
|
+
return COMPARISON.INVARIANT(equivalent, false, false, path, hint, dbc);
|
|
36
|
+
}
|
|
37
|
+
/** See {@link COMPARISON.constructor }. */
|
|
38
|
+
constructor(public override equivalent: any) {
|
|
39
|
+
super(equivalent, false, false);
|
|
40
|
+
}
|
|
41
|
+
}
|