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