xdbc 1.0.73

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/src/DBC/AE.ts ADDED
@@ -0,0 +1,247 @@
1
+ import { DBC } from "../DBC.js";
2
+ /**
3
+ * A {@link DBC } defining that all elements of an {@link object }s have to fulfill
4
+ * a given {@link object }'s check-method (( toCheck : any ) => boolean | string ).
5
+ *
6
+ * @remarks
7
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
8
+ export class AE extends DBC {
9
+ // #region Condition checking.
10
+ /**
11
+ * Checks each element of the "value"-{@link Array < any >} against the given "condition", if it is one. If it is not
12
+ * the "value" itself will be checked.
13
+ *
14
+ * @param condition The { check: (toCheck: any) => boolean | string } to check the "value" against.
15
+ * @param value Either "value"-{@link Array < any >}, which's elements will be checked, or the value to be
16
+ * checked itself.
17
+ * @param index If specified with "idxEnd" being undefined, this {@link Number } will be seen as the index of
18
+ * the value-{@link Array }'s element to check. If value isn't an {@link Array } this parameter
19
+ * will not have any effect.
20
+ * With "idxEnd" not undefined this parameter indicates the beginning of the span of elements to
21
+ * check within the value-{@link Array }.
22
+ * @param idxEnd Indicates the last element's index (including) of the span of value-{@link Array } elements to check.
23
+ * Setting this parameter to -1 specifies that all value-{@link Array }'s elements beginning from the
24
+ * specified "index" shall be checked.
25
+ *
26
+ * @returns As soon as the "condition" returns a {@link string }, instead of TRUE, the returned string. TRUE if the
27
+ * "condition" never returns a {@link string}. */
28
+ public static checkAlgorithm(
29
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
30
+ condition: { check: (toCheck: any) => boolean | string },
31
+ value: object,
32
+ index: number | undefined,
33
+ idxEnd: number | undefined,
34
+ ): boolean | string {
35
+ if (Array.isArray(value)) {
36
+ if (index !== undefined && idxEnd === undefined) {
37
+ if (index > -1 && index < value.length) {
38
+ const result = condition.check(value[index]);
39
+
40
+ if (typeof result === "string") {
41
+ return `Violating-Arrayelement at index "${index}" with value "${value[index]}". ${result}`;
42
+ }
43
+ }
44
+
45
+ return true; // In order for optional parameter to not cause an error if they are omitted.
46
+ }
47
+
48
+ for (
49
+ let i = index;
50
+ i <
51
+ (idxEnd !== undefined
52
+ ? idxEnd !== -1
53
+ ? idxEnd + 1
54
+ : (value as []).length
55
+ : (value as []).length);
56
+ i++
57
+ ) {
58
+ const result = condition.check(value[i]);
59
+
60
+ if (result !== true) {
61
+ return `Violating-Arrayelement at index ${i}. ${result}`;
62
+ }
63
+ }
64
+ } else {
65
+ return condition.check(value);
66
+ }
67
+
68
+ return true;
69
+ }
70
+ /**
71
+ * A parameter-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
72
+ * of the "realConditions" to check the tagged parameter-value against with.
73
+ * When specifying an "index" and the tagged parameter's "value" is an {@link Array }, the "realConditions" apply to the
74
+ * element at the specified "index".
75
+ * If the {@link Array } is too short the currently processed { check: (toCheck: any) => boolean | string } of
76
+ * "realConditions" will be verified to TRUE automatically, considering optional parameters.
77
+ * If an "index" is specified but the tagged parameter's value isn't an array, the "index" is treated as being undefined.
78
+ * If "index" is undefined and the tagged parameter's value is an {@link Array } each element of it will be checked
79
+ * against the "realConditions".
80
+ *
81
+ * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
82
+ * against with.
83
+ * @param index See the {@link AE.checkAlgorithm }.
84
+ * @param idxEnd See the {@link AE.checkAlgorithm }.
85
+ * @param path See {@link DBC.decPrecondition }.
86
+ * @param dbc See {@link DBC.decPrecondition }.
87
+ *
88
+ * @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of "realConditions" returns one.
89
+ * Otherwise TRUE. */
90
+ public static PRE(
91
+ realConditions: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
92
+ | Array<{ check: (toCheck: any) => boolean | string }>
93
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
94
+ | { check: (toCheck: any) => boolean | string },
95
+ index: number | undefined = undefined,
96
+ idxEnd: number | undefined = undefined,
97
+ path: string | undefined = undefined,
98
+ dbc = "WaXCode.DBC",
99
+ ): (
100
+ target: object,
101
+ methodName: string | symbol,
102
+ parameterIndex: number,
103
+ ) => void {
104
+ return DBC.decPrecondition(
105
+ (
106
+ value: object,
107
+ target: object,
108
+ methodName: string,
109
+ parameterIndex: number,
110
+ ) => {
111
+ if (Array.isArray(realConditions)) {
112
+ for (const currentCondition of realConditions) {
113
+ const result = AE.checkAlgorithm(
114
+ currentCondition,
115
+ value,
116
+ index,
117
+ idxEnd,
118
+ );
119
+
120
+ if (typeof result !== "boolean") return result;
121
+ }
122
+ } else {
123
+ return AE.checkAlgorithm(
124
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
125
+ realConditions as { check: (toCheck: any) => boolean | string },
126
+ value,
127
+ index,
128
+ idxEnd,
129
+ );
130
+ }
131
+
132
+ return true;
133
+ },
134
+ dbc,
135
+ path,
136
+ );
137
+ }
138
+ /**
139
+ * A method-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
140
+ * of the "realConditions" to check the tagged method's return-value against with.
141
+ *
142
+ * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
143
+ * against with.
144
+ * @param index See the {@link AE.checkAlgorithm }.
145
+ * @param idxEnd See the {@link AE.checkAlgorithm }.
146
+ * @param path See {@link DBC.decPrecondition }.
147
+ * @param dbc See {@link DBC.decPrecondition }.
148
+ *
149
+ * @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of "realConditions" return one.
150
+ * Otherwise TRUE. */
151
+ public static POST(
152
+ realConditions: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
153
+ | Array<{ check: (toCheck: any) => boolean | string }>
154
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
155
+ | { check: (toCheck: any) => boolean | string },
156
+ index: number | undefined = undefined,
157
+ idxEnd: number | undefined = undefined,
158
+ path: string | undefined = undefined,
159
+ dbc = "WaXCode.DBC",
160
+ ): (
161
+ target: object,
162
+ propertyKey: string,
163
+ descriptor: PropertyDescriptor,
164
+ ) => PropertyDescriptor {
165
+ return DBC.decPostcondition(
166
+ (value: object, target: object, propertyKey: string) => {
167
+ if (Array.isArray(realConditions)) {
168
+ for (const currentCondition of realConditions) {
169
+ const result = AE.checkAlgorithm(
170
+ currentCondition,
171
+ value,
172
+ index,
173
+ idxEnd,
174
+ );
175
+
176
+ if (typeof result !== "boolean") return result;
177
+ }
178
+ } else {
179
+ return AE.checkAlgorithm(
180
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
181
+ realConditions as { check: (toCheck: any) => boolean | string },
182
+ value,
183
+ index,
184
+ idxEnd,
185
+ );
186
+ }
187
+
188
+ return true;
189
+ },
190
+ dbc,
191
+ path,
192
+ );
193
+ }
194
+ // #endregion Condition checking.
195
+ // #region Referenced Condition checking.
196
+ //
197
+ // For usage in dynamic scenarios (like global functions).
198
+ //
199
+ /**
200
+ * Invokes the {@link AE.checkAlgorithm } passing the value "toCheck", {@link AE.equivalent } and {@link EQ.invert }.
201
+ *
202
+ * @param toCheck See {@link EQ.checkAlgorithm }.
203
+ *
204
+ * @returns See {@link EQ.checkAlgorithm}. */
205
+ public check(
206
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
207
+ toCheck: any,
208
+ ) {
209
+ if (Array.isArray(this.conditions)) {
210
+ for (const currentCondition of this.conditions) {
211
+ const result = AE.checkAlgorithm(
212
+ currentCondition,
213
+ toCheck,
214
+ this.index,
215
+ this.idxEnd,
216
+ );
217
+
218
+ if (typeof result !== "boolean") return result;
219
+ }
220
+ } else {
221
+ return AE.checkAlgorithm(
222
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
223
+ this.conditions as { check: (toCheck: any) => boolean | string },
224
+ toCheck,
225
+ this.index,
226
+ this.idxEnd,
227
+ );
228
+ }
229
+
230
+ return true;
231
+ }
232
+ /**
233
+ * Creates this {@link AE } by setting the protected property {@link AE.conditions }, {@link AE.index } and {@link AE.idxEnd } used by {@link AE.check }.
234
+ *
235
+ * @param equivalent See {@link EQ.check }. */
236
+ public constructor(
237
+ protected conditions: // biome-ignore lint/suspicious/noExplicitAny: <explanation>
238
+ | Array<{ check: (toCheck: any) => boolean | string }>
239
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
240
+ | { check: (toCheck: any) => boolean | string },
241
+ protected index: number | undefined = undefined,
242
+ protected idxEnd: number | undefined = undefined,
243
+ ) {
244
+ super();
245
+ }
246
+ // #endregion Referenced Condition checking.
247
+ }
package/src/DBC/EQ.ts ADDED
@@ -0,0 +1,121 @@
1
+ import { DBC } from "../DBC.js";
2
+ /**
3
+ * A {@link DBC } defining that two {@link object }s gotta be equal.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class EQ extends DBC {
8
+ // #region Condition checking.
9
+ /**
10
+ * Checks if the value "toCheck" is equal to the specified "equivalent".
11
+ *
12
+ * @param toCheck The value that has to be equal to it's possible "equivalent" for this {@link DBC } to be fulfilled.
13
+ * @param equivalent The {@link object } the one "toCheck" has to be equal to in order for this {@link DBC } to be
14
+ * fulfilled.
15
+ *
16
+ * @returns TRUE if the value "toCheck" and the "equivalent" are equal to each other, otherwise FALSE. */
17
+ public static checkAlgorithm(
18
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
19
+ toCheck: any,
20
+ equivalent: object,
21
+ invert,
22
+ ): boolean | string {
23
+ if (!invert && equivalent !== toCheck) {
24
+ return `Value has to to be equal to "${equivalent}"`;
25
+ }
26
+
27
+ if (invert && equivalent === toCheck) {
28
+ return `Value must not to be equal to "${equivalent}"`;
29
+ }
30
+
31
+ return true;
32
+ }
33
+ /**
34
+ * A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
35
+ * by the tagged parameter.
36
+ *
37
+ * @param equivalent See {@link EQ.checkAlgorithm }.
38
+ * @param path See {@link DBC.decPrecondition }.
39
+ * @param dbc See {@link DBC.decPrecondition }.
40
+ *
41
+ * @returns See {@link DBC.decPrecondition }. */
42
+ public static PRE(
43
+ // biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
44
+ equivalent: any,
45
+ invert = false,
46
+ path: string | undefined = undefined,
47
+ dbc = "WaXCode.DBC",
48
+ ): (
49
+ target: object,
50
+ methodName: string | symbol,
51
+ parameterIndex: number,
52
+ ) => void {
53
+ return DBC.decPrecondition(
54
+ (
55
+ value: object,
56
+ target: object,
57
+ methodName: string,
58
+ parameterIndex: number,
59
+ ) => {
60
+ return EQ.checkAlgorithm(value, equivalent, invert);
61
+ },
62
+ dbc,
63
+ path,
64
+ );
65
+ }
66
+ /**
67
+ * A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
68
+ * by the tagged method's returnvalue.
69
+ *
70
+ * @param equivalent See {@link EQ.checkAlgorithm }.
71
+ * @param path See {@link DBC.Postcondition }.
72
+ * @param dbc See {@link DBC.decPostcondition }.
73
+ *
74
+ * @returns See {@link DBC.decPostcondition }. */
75
+ public static POST(
76
+ // biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
77
+ equivalent: any,
78
+ invert = false,
79
+ path: string | undefined = undefined,
80
+ dbc = "WaXCode.DBC",
81
+ ): (
82
+ target: object,
83
+ propertyKey: string,
84
+ descriptor: PropertyDescriptor,
85
+ ) => PropertyDescriptor {
86
+ return DBC.decPostcondition(
87
+ (value: object, target: object, propertyKey: string) => {
88
+ return EQ.checkAlgorithm(value, equivalent, invert);
89
+ },
90
+ dbc,
91
+ path,
92
+ );
93
+ }
94
+ // #endregion Condition checking.
95
+ // #region Referenced Condition checking.
96
+ //
97
+ // For usage in dynamic scenarios (like with AE-DBC).
98
+ //
99
+ /**
100
+ * Invokes the {@link EQ.checkAlgorithm } passing the value "toCheck", {@link EQ.equivalent } and {@link EQ.invert }.
101
+ *
102
+ * @param toCheck See {@link EQ.checkAlgorithm }.
103
+ *
104
+ * @returns See {@link EQ.checkAlgorithm}. */
105
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
106
+ public check(toCheck: any) {
107
+ return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
108
+ }
109
+ /**
110
+ * Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
111
+ *
112
+ * @param equivalent See {@link EQ.check }. */
113
+ public constructor(
114
+ // biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
115
+ protected equivalent: any,
116
+ protected invert = false,
117
+ ) {
118
+ super();
119
+ }
120
+ // #endregion Referenced Condition checking.
121
+ }
@@ -0,0 +1,107 @@
1
+ import { DBC } from "../DBC.js";
2
+ /**
3
+ * A {@link DBC } defining that the an {@link object }s gotta be an instance of a certain {@link INSTANCE.reference }.
4
+ *
5
+ * @remarks
6
+ * Author: Salvatore Callari (Callari@WaXCode.net) / 2025
7
+ * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
8
+ export class INSTANCE extends DBC {
9
+ /**
10
+ * Checks if the value "toCheck" is complies to the {@link RegExp } "expression".
11
+ *
12
+ * @param toCheck The value that has comply to the {@link RegExp } "expression" for this {@link DBC } to be fulfilled.
13
+ * @param reference The {@link RegExp } the one "toCheck" has comply to in order for this {@link DBC } to be
14
+ * fulfilled.
15
+ *
16
+ * @returns TRUE if the value "toCheck" is of the specified "type", otherwise FALSE. */
17
+ // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
18
+ public static checkAlgorithm(toCheck: any, reference: any): boolean | string {
19
+ if (!(toCheck instanceof reference)) {
20
+ return `Value has to be an instance of "${reference}" but is of type "${typeof toCheck}"`;
21
+ }
22
+
23
+ return true;
24
+ }
25
+ /**
26
+ * A parameter-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
27
+ * by the tagged parameter.
28
+ *
29
+ * @param reference See {@link INSTANCE.checkAlgorithm }.
30
+ * @param path See {@link DBC.decPrecondition }.
31
+ * @param dbc See {@link DBC.decPrecondition }.
32
+ *
33
+ * @returns See {@link DBC.decPrecondition }. */
34
+ public static PRE(
35
+ // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
36
+ reference: any,
37
+ path: string | undefined = undefined,
38
+ dbc = "WaXCode.DBC",
39
+ ): (
40
+ target: object,
41
+ methodName: string | symbol,
42
+ parameterIndex: number,
43
+ ) => void {
44
+ return DBC.decPrecondition(
45
+ (
46
+ value: object,
47
+ target: object,
48
+ methodName: string,
49
+ parameterIndex: number,
50
+ ) => {
51
+ return INSTANCE.checkAlgorithm(value, reference);
52
+ },
53
+ dbc,
54
+ path,
55
+ );
56
+ }
57
+ /**
58
+ * A method-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
59
+ * by the tagged method's returnvalue.
60
+ *
61
+ * @param reference See {@link INSTANCE.checkAlgorithm }.
62
+ * @param path See {@link DBC.Postcondition }.
63
+ * @param dbc See {@link DBC.decPostcondition }.
64
+ *
65
+ * @returns See {@link DBC.decPostcondition }. */
66
+ public static POST(
67
+ // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
68
+ reference: any,
69
+ path: string | undefined = undefined,
70
+ dbc = "WaXCode.DBC",
71
+ ): (
72
+ target: object,
73
+ propertyKey: string,
74
+ descriptor: PropertyDescriptor,
75
+ ) => PropertyDescriptor {
76
+ return DBC.decPostcondition(
77
+ (value: object, target: object, propertyKey: string) => {
78
+ return INSTANCE.checkAlgorithm(value, reference);
79
+ },
80
+ dbc,
81
+ path,
82
+ );
83
+ }
84
+ // #endregion Condition checking.
85
+ // #region Referenced Condition checking.
86
+ //
87
+ // For usage in dynamic scenarios (like with AE-DBC).
88
+ //
89
+ /**
90
+ * Invokes the {@link INSTANCE.checkAlgorithm } passing the value "toCheck" and the {@link INSTANCE.reference } .
91
+ *
92
+ * @param toCheck See {@link INSTANCE.checkAlgorithm }.
93
+ *
94
+ * @returns See {@link INSTANCE.checkAlgorithm}. */
95
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
96
+ public check(toCheck: any) {
97
+ return INSTANCE.checkAlgorithm(toCheck, this.reference);
98
+ }
99
+ /**
100
+ * Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
101
+ *
102
+ * @param reference See {@link INSTANCE.check }. */
103
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
104
+ public constructor(protected reference: any) {
105
+ super();
106
+ }
107
+ }
@@ -0,0 +1,179 @@
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } demanding that an {@link object } has specific properties of specific types.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class JSON_OP extends DBC {
8
+ // #region Condition checking.
9
+ /**
10
+ * Checks if the object "toCheck" has the "necessaryProperties" of necessary type.
11
+ *
12
+ * @param toCheck The {@link object } to check for the necessary properties.
13
+ * @param necessaryProperties The { name : string, type : string }s defining the properties and type the {@link object } to
14
+ * check needs to have.
15
+ * @param checkElements Indicates if "toCheck" is an iterable object of which all elements have to be checked.
16
+ * Elements will only be checked if "toCheck" is iterable, otherwise "toCheck" itself
17
+ * will be checked.
18
+ *
19
+ * @returns TRUE if the value "toCheck" or it's elements, if "checkElements is TRUE, has all "necessaryProperties", otherwise a {@link string } to report the infringement. */
20
+ public static checkAlgorithm(
21
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
22
+ toCheck: any,
23
+ necessaryProperties: Array<{ name: string; type: string }>,
24
+ checkElements,
25
+ ): boolean | string {
26
+ if (toCheck === undefined || null) {
27
+ return `[ UNDEFINED or NULL received instead of object with following properties: ${JSON.stringify(necessaryProperties)} ]`;
28
+ }
29
+
30
+ for (const property of necessaryProperties)
31
+ if (checkElements && typeof toCheck[Symbol.iterator] === "function") {
32
+ for (const element of toCheck) {
33
+ if (
34
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
35
+ !element.hasOwnProperty(property.name) ||
36
+ // biome-ignore lint/suspicious/useValidTypeof: <explanation>
37
+ typeof element[property.name] !== property.type
38
+ ) {
39
+ return `[ Object "${JSON.stringify(element)}" in Array "${JSON.stringify(toCheck)}" does not contain the necessary property "${property.name}" of type "${property.type}"]`;
40
+ }
41
+ }
42
+ } else {
43
+ if (
44
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
45
+ !toCheck.hasOwnProperty(property.name) ||
46
+ // biome-ignore lint/suspicious/useValidTypeof: <explanation>
47
+ typeof toCheck[property.name] !== property.type
48
+ ) {
49
+ return `[ Object does not contain the necessary property "${property.name}" of type "${property.type}"]`;
50
+ }
51
+ }
52
+
53
+ return true;
54
+ }
55
+ /**
56
+ * A parameter-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
57
+ * by the tagged parameter.
58
+ *
59
+ * @param expression See {@link JSON.checkAlgorithm }.
60
+ * @param path See {@link DBC.decPrecondition }.
61
+ * @param dbc See {@link DBC.decPrecondition }.
62
+ *
63
+ * @returns See {@link DBC.decPrecondition }. */
64
+ public static PRE(
65
+ necessaryProperties: Array<{ name: string; type: string }>,
66
+ checkElements = false,
67
+ path: string | undefined = undefined,
68
+ dbc = "WaXCode.DBC",
69
+ ): (
70
+ target: object,
71
+ methodName: string | symbol,
72
+ parameterIndex: number,
73
+ ) => void {
74
+ return DBC.decPrecondition(
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
+ );
90
+ }
91
+ /**
92
+ * A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
93
+ * by the tagged method's returnvalue.
94
+ *
95
+ * @param expression See {@link JSON.checkAlgorithm }.
96
+ * @param path See {@link DBC.Postcondition }.
97
+ * @param dbc See {@link DBC.decPostcondition }.
98
+ *
99
+ * @returns See {@link DBC.decPostcondition }. */
100
+ public static POST(
101
+ necessaryProperties: Array<{ name: string; type: string }>,
102
+ checkElements = false,
103
+ path: string | undefined = undefined,
104
+ dbc = "WaXCode.DBC",
105
+ ): (
106
+ target: object,
107
+ propertyKey: string,
108
+ descriptor: PropertyDescriptor,
109
+ ) => PropertyDescriptor {
110
+ return DBC.decPostcondition(
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
+ );
122
+ }
123
+ // #endregion Condition checking.
124
+ // #region Referenced Condition checking.
125
+ //
126
+ // For usage in dynamic scenarios (like with AE-DBC).
127
+ //
128
+ /**
129
+ * Invokes the {@link JSON_OP.checkAlgorithm } passing the value "toCheck", {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
130
+ *
131
+ * @param toCheck See {@link JSON_OP.checkAlgorithm }.
132
+ *
133
+ * @returns See {@link JSON_OP.checkAlgorithm}. */
134
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
135
+ public check(toCheck: any) {
136
+ return JSON_OP.checkAlgorithm(
137
+ toCheck,
138
+ this.necessaryProperties,
139
+ this.checkElements,
140
+ );
141
+ }
142
+ /**
143
+ * Creates this {@link JSON_OP } by setting the protected property {@link JSON_OP.necessaryProperties } and {@link checkElements } used by {@link JSON_OP.check }.
144
+ *
145
+ * @param necessaryProperties See {@link JSON_OP.check }.
146
+ * @param checkElements See {@link JSON_OP.check }. */
147
+ public constructor(
148
+ public necessaryProperties: Array<{ name: string; type: string }>,
149
+ public checkElements = false,
150
+ ) {
151
+ super();
152
+ }
153
+ // #endregion Referenced Condition checking.
154
+ // #region In-Method checking.
155
+ /**
156
+ * Invokes the {@link JSON_OP.checkAlgorithm } passing the value "toCheck", {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
157
+ *
158
+ * @param toCheck See {@link JSON_OP.checkAlgorithm} }.
159
+ * @param necessaryProperties See {@link JSON_OP.checkAlgorithm} }.
160
+ * @param checkElements See {@link JSON_OP.checkAlgorithm} }.
161
+ */
162
+ public static check(
163
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
164
+ toCheck: any,
165
+ necessaryProperties: Array<{ name: string; type: string }>,
166
+ checkElements = false,
167
+ ) {
168
+ const checkResult = JSON_OP.checkAlgorithm(
169
+ toCheck,
170
+ necessaryProperties,
171
+ checkElements,
172
+ );
173
+
174
+ if (typeof checkResult === "string") {
175
+ throw new DBC.Infringement(checkResult);
176
+ }
177
+ }
178
+ // #endregion In-Method checking.
179
+ }