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/IF.ts CHANGED
@@ -1,179 +1,173 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining that an {@link object } has also to comply to a certain {@link DBC } if it complies to
4
- * another specified one.
5
- *
6
- * @remarks
7
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
8
- export class IF extends DBC {
9
- // #region Condition checking.
10
- /**
11
- * Checks if the value **toCheck** complies to the specified **condition** and if so does also comply to the one **inCase**.
12
- *
13
- * @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
14
- * @param condition The contract **toCheck** has to comply to in order to also have to comply to the one **inCase**.
15
- * @param inCase The contract **toCheck** has to also comply to if it complies to **condition**.
16
- *
17
- * @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
18
- public static checkAlgorithm(
19
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
20
- toCheck: any,
21
- condition: {
22
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
23
- },
24
- inCase: {
25
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
26
- },
27
- invert = false,
28
- ): boolean | string {
29
- if (toCheck === undefined || toCheck === null) return true;
30
-
31
- if (
32
- invert &&
33
- condition.check(toCheck) !== true &&
34
- inCase.check(toCheck) !== true
35
- ) {
36
- return "In case that the value does not comply to the condition, it also has to comply to the required contract";
37
- }
38
-
39
- if (
40
- !invert &&
41
- condition.check(toCheck) === true &&
42
- inCase.check(toCheck) !== true
43
- ) {
44
- return "In case that the value complies to the condition, it has to comply to the required contract";
45
- }
46
-
47
- return true;
48
- }
49
- /**
50
- * A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
51
- * by the tagged parameter.
52
- *
53
- * @param condition See {@link IF.checkAlgorithm }.
54
- * @param inCase See {@link IF.checkAlgorithm }.
55
- * @param path See {@link DBC.decPrecondition }.
56
- * @param dbc See {@link DBC.decPrecondition }.
57
- *
58
- * @returns See {@link DBC.decPrecondition }. */
59
- public static PRE(
60
- condition: {
61
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
62
- },
63
- inCase: {
64
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
65
- },
66
- path: string | undefined = undefined,
67
- invert = false,
68
- hint: string | undefined = undefined,
69
- dbc: string | undefined = undefined,
70
- ): (
71
- target: object,
72
- methodName: string | symbol | undefined,
73
- parameterIndex: number,
74
- ) => void {
75
- return DBC.createPRE(
76
- IF.checkAlgorithm,
77
- [condition, inCase, invert],
78
- dbc,
79
- path,
80
- hint,
81
- );
82
- }
83
- /**
84
- * A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
85
- * by the tagged method's returnvalue.
86
- *
87
- * @param condition See {@link IF.checkAlgorithm }.
88
- * @param inCase See {@link IF.checkAlgorithm }.
89
- * @param path See {@link DBC.Postcondition }.
90
- * @param dbc See {@link DBC.decPostcondition }.
91
- *
92
- * @returns See {@link DBC.decPostcondition }. */
93
- public static POST(
94
- condition: {
95
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
96
- },
97
- inCase: {
98
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
99
- },
100
- path: string | undefined = undefined,
101
- invert = false,
102
- hint: string | undefined = undefined,
103
- dbc: string | undefined = undefined,
104
- ): (
105
- target: object,
106
- propertyKey: string,
107
- descriptor: PropertyDescriptor,
108
- ) => PropertyDescriptor {
109
- return DBC.createPOST(
110
- IF.checkAlgorithm,
111
- [condition, inCase, invert],
112
- dbc,
113
- path,
114
- hint,
115
- );
116
- }
117
- /**
118
- * A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
119
- * by the tagged field.
120
- *
121
- * @param condition See {@link IF.checkAlgorithm }.
122
- * @param inCase See {@link IF.checkAlgorithm }.
123
- * @param path See {@link DBC.decInvariant }.
124
- * @param dbc See {@link DBC.decInvariant }.
125
- *
126
- * @returns See {@link DBC.decInvariant }. */
127
- public static INVARIANT(
128
- condition: {
129
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
130
- },
131
- inCase: {
132
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
133
- },
134
- path: string | undefined = undefined,
135
- invert = false,
136
- hint: string | undefined = undefined,
137
- dbc: string | undefined = undefined,
138
- ) {
139
- return DBC.createINVARIANT(
140
- IF,
141
- [condition, inCase, invert],
142
- dbc,
143
- path,
144
- hint,
145
- );
146
- }
147
- // #endregion Condition checking.
148
- // #region Referenced Condition checking.
149
- //
150
- // For usage in dynamic scenarios (like with AE-DBC).
151
- //
152
- /**
153
- * Invokes the {@link IF.checkAlgorithm } passing the value **toCheck**, {@link IF.equivalent } and {@link IF.invert }.
154
- *
155
- * @param toCheck See {@link IF.checkAlgorithm }.
156
- *
157
- * @returns See {@link IF.checkAlgorithm}. */
158
- // biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
159
- public check(toCheck: any) {
160
- return IF.checkAlgorithm(toCheck, this.condition, this.inCase, this.invert);
161
- }
162
- /**
163
- * Creates this {@link IF } by setting the protected property {@link IF.equivalent } used by {@link IF.check }.
164
- *
165
- * @param equivalent See {@link IF.check }. */
166
- public constructor(
167
- // biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
168
- protected condition: {
169
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
170
- },
171
- protected inCase: {
172
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
173
- },
174
- protected invert = false,
175
- ) {
176
- super();
177
- }
178
- // #endregion Referenced Condition checking.
179
- }
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } defining that an {@link object } has also to comply to a certain {@link DBC } if it complies to
4
+ * another specified one.
5
+ *
6
+ * @remarks
7
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
8
+ export class IF extends DBC {
9
+ // #region Condition checking.
10
+ /**
11
+ * Checks if the value **toCheck** complies to the specified **condition** and if so does also comply to the one **inCase**.
12
+ *
13
+ * @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
14
+ * @param condition The contract **toCheck** has to comply to in order to also have to comply to the one **inCase**.
15
+ * @param inCase The contract **toCheck** has to also comply to if it complies to **condition**.
16
+ *
17
+ * @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
18
+ public static checkAlgorithm(
19
+ toCheck: any,
20
+ condition: {
21
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
22
+ },
23
+ inCase: {
24
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
25
+ },
26
+ invert = false,
27
+ ): boolean | string {
28
+ if (toCheck === undefined || toCheck === null) return true;
29
+ if (
30
+ invert &&
31
+ condition.check(toCheck) !== true &&
32
+ inCase.check(toCheck) !== true
33
+ ) {
34
+ return "In case that the value does not comply to the condition, it also has to comply to the required contract";
35
+ }
36
+ if (
37
+ !invert &&
38
+ condition.check(toCheck) === true &&
39
+ inCase.check(toCheck) !== true
40
+ ) {
41
+ return "In case that the value complies to the condition, it has to comply to the required contract";
42
+ }
43
+ return true;
44
+ }
45
+ /**
46
+ * A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
47
+ * by the tagged parameter.
48
+ *
49
+ * @param condition See {@link IF.checkAlgorithm }.
50
+ * @param inCase See {@link IF.checkAlgorithm }.
51
+ * @param path See {@link DBC.decPrecondition }.
52
+ * @param dbc See {@link DBC.decPrecondition }.
53
+ *
54
+ * @returns See {@link DBC.decPrecondition }. */
55
+ public static PRE(
56
+ condition: {
57
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
58
+ },
59
+ inCase: {
60
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
61
+ },
62
+ path: string | undefined = undefined,
63
+ invert = false,
64
+ hint: string | undefined = undefined,
65
+ dbc: string | undefined = undefined,
66
+ ): (
67
+ target: object,
68
+ methodName: string | symbol | undefined,
69
+ parameterIndex: number,
70
+ ) => void {
71
+ return DBC.createPRE(
72
+ IF.checkAlgorithm,
73
+ [condition, inCase, invert],
74
+ dbc,
75
+ path,
76
+ hint,
77
+ );
78
+ }
79
+ /**
80
+ * A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
81
+ * by the tagged method's returnvalue.
82
+ *
83
+ * @param condition See {@link IF.checkAlgorithm }.
84
+ * @param inCase See {@link IF.checkAlgorithm }.
85
+ * @param path See {@link DBC.Postcondition }.
86
+ * @param dbc See {@link DBC.decPostcondition }.
87
+ *
88
+ * @returns See {@link DBC.decPostcondition }. */
89
+ public static POST(
90
+ condition: {
91
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
92
+ },
93
+ inCase: {
94
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
95
+ },
96
+ path: string | undefined = undefined,
97
+ invert = false,
98
+ hint: string | undefined = undefined,
99
+ dbc: string | undefined = undefined,
100
+ ): (
101
+ target: object,
102
+ propertyKey: string,
103
+ descriptor: PropertyDescriptor,
104
+ ) => PropertyDescriptor {
105
+ return DBC.createPOST(
106
+ IF.checkAlgorithm,
107
+ [condition, inCase, invert],
108
+ dbc,
109
+ path,
110
+ hint,
111
+ );
112
+ }
113
+ /**
114
+ * A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
115
+ * by the tagged field.
116
+ *
117
+ * @param condition See {@link IF.checkAlgorithm }.
118
+ * @param inCase See {@link IF.checkAlgorithm }.
119
+ * @param path See {@link DBC.decInvariant }.
120
+ * @param dbc See {@link DBC.decInvariant }.
121
+ *
122
+ * @returns See {@link DBC.decInvariant }. */
123
+ public static INVARIANT(
124
+ condition: {
125
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
126
+ },
127
+ inCase: {
128
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
129
+ },
130
+ path: string | undefined = undefined,
131
+ invert = false,
132
+ hint: string | undefined = undefined,
133
+ dbc: string | undefined = undefined,
134
+ ) {
135
+ return DBC.createINVARIANT(
136
+ IF,
137
+ [condition, inCase, invert],
138
+ dbc,
139
+ path,
140
+ hint,
141
+ );
142
+ }
143
+ // #endregion Condition checking.
144
+ // #region Referenced Condition checking.
145
+ //
146
+ // For usage in dynamic scenarios (like with AE-DBC).
147
+ //
148
+ /**
149
+ * Invokes the {@link IF.checkAlgorithm } passing the value **toCheck**, {@link IF.equivalent } and {@link IF.invert }.
150
+ *
151
+ * @param toCheck See {@link IF.checkAlgorithm }.
152
+ *
153
+ * @returns See {@link IF.checkAlgorithm}. */
154
+ public check(toCheck: any) {
155
+ return IF.checkAlgorithm(toCheck, this.condition, this.inCase, this.invert);
156
+ }
157
+ /**
158
+ * Creates this {@link IF } by setting the protected property {@link IF.equivalent } used by {@link IF.check }.
159
+ *
160
+ * @param equivalent See {@link IF.check }. */
161
+ public constructor(
162
+ protected condition: {
163
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
164
+ },
165
+ protected inCase: {
166
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
167
+ },
168
+ protected invert = false,
169
+ ) {
170
+ super();
171
+ }
172
+ // #endregion Referenced Condition checking.
173
+ }