xdbc 1.0.211 → 1.0.213

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 (88) hide show
  1. package/.gitattributes +8 -0
  2. package/.github/workflows/ci.yml +51 -0
  3. package/.vscode/tasks.json +23 -23
  4. package/CODE_OF_CONDUCT.md +1 -1
  5. package/README.md +1 -0
  6. package/__tests__/DBC/AE.test.ts +1 -1
  7. package/__tests__/DBC/DEFINED.test.ts +49 -49
  8. package/__tests__/DBC/Decorators.test.ts +334 -332
  9. package/__tests__/DBC/HasAttribute.test.ts +56 -52
  10. package/__tests__/DBC/IF.test.ts +57 -57
  11. package/__tests__/DBC/OR.test.ts +1 -1
  12. package/__tests__/DBC/UNDEFINED.test.ts +41 -41
  13. package/__tests__/DBC/ZOD.test.ts +50 -50
  14. package/biome.json +40 -33
  15. package/dist/DBC/AE.d.ts +117 -0
  16. package/dist/DBC/COMPARISON/GREATER.d.ts +13 -0
  17. package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.d.ts +13 -0
  18. package/dist/DBC/COMPARISON/LESS.d.ts +13 -0
  19. package/dist/DBC/COMPARISON/LESS_OR_EQUAL.d.ts +13 -0
  20. package/dist/DBC/COMPARISON.d.ts +70 -0
  21. package/dist/DBC/DEFINED.d.ts +62 -0
  22. package/dist/DBC/EQ/DIFFERENT.d.ts +26 -0
  23. package/dist/DBC/EQ.d.ts +70 -0
  24. package/dist/DBC/HasAttribute.d.ts +72 -0
  25. package/dist/DBC/IF.d.ts +90 -0
  26. package/dist/DBC/INSTANCE.d.ts +84 -0
  27. package/dist/DBC/JSON.OP.d.ts +94 -0
  28. package/dist/DBC/JSON.Parse.d.ts +69 -0
  29. package/dist/DBC/OR.d.ts +104 -0
  30. package/dist/DBC/REGEX.d.ts +96 -0
  31. package/dist/DBC/TYPE.d.ts +75 -0
  32. package/dist/DBC/UNDEFINED.d.ts +62 -0
  33. package/dist/DBC/ZOD.d.ts +72 -0
  34. package/dist/DBC.d.ts +244 -0
  35. package/dist/Demo.d.ts +20 -0
  36. package/dist/bundle.js +2297 -0
  37. package/docs/assets/highlight.css +22 -22
  38. package/docs/assets/icons.js +17 -17
  39. package/docs/assets/main.js +60 -60
  40. package/docs/assets/style.css +1640 -1640
  41. package/docs/classes/DBC.DBC.html +98 -98
  42. package/docs/classes/DBC_AE.AE.html +160 -160
  43. package/docs/classes/DBC_EQ.EQ.html +131 -131
  44. package/docs/classes/DBC_GREATER.GREATER.html +139 -139
  45. package/docs/classes/DBC_INSTANCE.INSTANCE.html +130 -130
  46. package/docs/classes/DBC_JSON.OP.JSON_OP.html +138 -138
  47. package/docs/classes/DBC_JSON.Parse.JSON_Parse.html +129 -129
  48. package/docs/classes/DBC_OR.OR.html +137 -137
  49. package/docs/classes/DBC_REGEX.REGEX.html +136 -136
  50. package/docs/classes/DBC_TYPE.TYPE.html +130 -130
  51. package/docs/classes/Demo.Demo.html +14 -14
  52. package/docs/hierarchy.html +1 -1
  53. package/docs/index.html +1 -1
  54. package/docs/modules/DBC.html +1 -1
  55. package/docs/modules/DBC_AE.html +1 -1
  56. package/docs/modules/DBC_EQ.html +1 -1
  57. package/docs/modules/DBC_GREATER.html +1 -1
  58. package/docs/modules/DBC_INSTANCE.html +1 -1
  59. package/docs/modules/DBC_JSON.OP.html +1 -1
  60. package/docs/modules/DBC_JSON.Parse.html +1 -1
  61. package/docs/modules/DBC_OR.html +1 -1
  62. package/docs/modules/DBC_REGEX.html +1 -1
  63. package/docs/modules/DBC_TYPE.html +1 -1
  64. package/docs/modules/Demo.html +1 -1
  65. package/jest.config.js +29 -18
  66. package/package.json +6 -2
  67. package/src/DBC/AE.ts +14 -9
  68. package/src/DBC/COMPARISON/GREATER.ts +2 -2
  69. package/src/DBC/COMPARISON.ts +159 -136
  70. package/src/DBC/DEFINED.ts +10 -10
  71. package/src/DBC/EQ/DIFFERENT.ts +3 -3
  72. package/src/DBC/EQ.ts +25 -9
  73. package/src/DBC/HasAttribute.ts +17 -3
  74. package/src/DBC/IF.ts +63 -19
  75. package/src/DBC/INSTANCE.ts +29 -14
  76. package/src/DBC/JSON.OP.ts +18 -3
  77. package/src/DBC/JSON.Parse.ts +21 -4
  78. package/src/DBC/OR.ts +12 -7
  79. package/src/DBC/REGEX.ts +30 -21
  80. package/src/DBC/TYPE.ts +15 -11
  81. package/src/DBC/UNDEFINED.ts +7 -10
  82. package/src/DBC/ZOD.ts +14 -9
  83. package/src/DBC.ts +165 -69
  84. package/src/Demo.ts +21 -18
  85. package/test.drawio +0 -0
  86. package/tsconfig.json +3 -5
  87. package/tsconfig.test.json +6 -11
  88. package/webpack.config.js +1 -1
@@ -1,136 +1,159 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining a comparison between two {@link object }s.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class COMPARISON extends DBC {
8
- // #region Condition checking.
9
- /**
10
- * Does a comparison between the {@link object } **toCheck** and the **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
- // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic comparison
18
- static checkAlgorithm(toCheck: any, equivalent: any, equalityPermitted: boolean, invert: boolean) {
19
- if (equalityPermitted && !invert && toCheck < equivalent) {
20
- return `Value has to be greater than or equal to "${equivalent}"`;
21
- }
22
-
23
- if (equalityPermitted && invert && toCheck > equivalent) {
24
- return `Value has to be less than or equal to "${equivalent}"`;
25
- }
26
-
27
- if (!equalityPermitted && !invert && toCheck <= equivalent) {
28
- return `Value has to be greater than "${equivalent}"`;
29
- }
30
-
31
- if (!equalityPermitted && invert && toCheck >= equivalent) {
32
- return `Value has to be less than "${equivalent}"`;
33
- }
34
-
35
- return true;
36
- }
37
- /**
38
- * A parameter-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
39
- * by the tagged parameter.
40
- *
41
- * @param equivalent See {@link COMPARISON.checkAlgorithm }.
42
- * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
43
- * @param path See {@link DBC.decPrecondition }.
44
- * @param hint See {@link DBC.decPrecondition }.
45
- * @param dbc See {@link DBC.decPrecondition }.
46
- *
47
- * @returns See {@link DBC.decPrecondition }. */
48
- static PRE(
49
- // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
50
- equivalent: any,
51
- equalityPermitted = false,
52
- invert = false,
53
- path: string | undefined = undefined,
54
- hint: string | undefined = undefined,
55
- dbc: string | undefined = undefined,
56
- ) {
57
- return DBC.createPRE(COMPARISON.checkAlgorithm, [equivalent, equalityPermitted, invert], dbc, path, hint);
58
- }
59
- /**
60
- * A method-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
61
- * by the tagged method's returnvalue.
62
- *
63
- * @param equivalent See {@link COMPARISON.checkAlgorithm }.
64
- * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
65
- * @param path See {@link DBC.Postcondition }.
66
- * @param hint See {@link DBC.decPostcondition }.
67
- * @param dbc See {@link DBC.decPostcondition }.
68
- *
69
- * @returns See {@link DBC.decPostcondition }. */
70
- static POST(
71
- // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
72
- equivalent: any,
73
- equalityPermitted = false,
74
- invert = false,
75
- path: string | undefined = undefined,
76
- hint: string | undefined = undefined,
77
- dbc: string | undefined = undefined,
78
- ) {
79
- return DBC.createPOST(COMPARISON.checkAlgorithm, [equivalent, equalityPermitted, invert], dbc, path, hint);
80
- }
81
- /**
82
- * A field-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
83
- * by the tagged field.
84
- *
85
- * @param equivalent See {@link COMPARISON.checkAlgorithm }.
86
- * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
87
- * @param path See {@link DBC.decInvariant }.
88
- * @param hint See {@link DBC.decInvariant }.
89
- * @param dbc See {@link DBC.decInvariant }.
90
- *
91
- * @returns See {@link DBC.decInvariant }. */
92
- static INVARIANT(
93
- // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
94
- equivalent: any,
95
- equalityPermitted = false,
96
- invert = false,
97
- path: string | undefined = undefined,
98
- hint: string | undefined = undefined,
99
- dbc: string | undefined = undefined,
100
- ) {
101
- return DBC.createINVARIANT(COMPARISON, [equivalent, equalityPermitted, invert], dbc, path, hint);
102
- }
103
- // #endregion Condition checking.
104
- // #region Referenced Condition checking.
105
- // #region Dynamic usage.
106
- /**
107
- * Invokes the {@link COMPARISON.checkAlgorithm } passing the value **toCheck**, {@link COMPARISON.equivalent } and {@link COMPARISON.invert }.
108
- *
109
- * @param toCheck See {@link COMPARISON.checkAlgorithm }.
110
- *
111
- * @returns See {@link COMPARISON.checkAlgorithm}. */
112
- // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic comparison
113
- public check(toCheck: any) {
114
- return COMPARISON.checkAlgorithm(
115
- toCheck,
116
- this.equivalent,
117
- this.equalityPermitted,
118
- this.invert,
119
- );
120
- }
121
- /**
122
- * Creates this {@link COMPARISON } by setting the protected property {@link COMPARISON.equivalent }, {@link COMPARISON.equalityPermitted } and {@link COMPARISON.invert } used by {@link COMPARISON.check }.
123
- *
124
- * @param equivalent See {@link COMPARISON.check }.
125
- * @param equalityPermitted See {@link COMPARISON.check }.
126
- * @param invert See {@link COMPARISON.check }. */
127
- constructor(
128
- // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
129
- public equivalent: any,
130
- public equalityPermitted = false,
131
- public invert = false,
132
- ) {
133
- super();
134
- }
135
- // #endregion Dynamic usage.
136
- }
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } defining a comparison between two {@link object }s.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class COMPARISON extends DBC {
8
+ // #region Condition checking.
9
+ /**
10
+ * Does a comparison between the {@link object } **toCheck** and the **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
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic comparison
18
+ static checkAlgorithm(
19
+ toCheck: any,
20
+ equivalent: any,
21
+ equalityPermitted: boolean,
22
+ invert: boolean,
23
+ ) {
24
+ if (equalityPermitted && !invert && toCheck < equivalent) {
25
+ return `Value has to be greater than or equal to "${equivalent}"`;
26
+ }
27
+
28
+ if (equalityPermitted && invert && toCheck > equivalent) {
29
+ return `Value has to be less than or equal to "${equivalent}"`;
30
+ }
31
+
32
+ if (!equalityPermitted && !invert && toCheck <= equivalent) {
33
+ return `Value has to be greater than "${equivalent}"`;
34
+ }
35
+
36
+ if (!equalityPermitted && invert && toCheck >= equivalent) {
37
+ return `Value has to be less than "${equivalent}"`;
38
+ }
39
+
40
+ return true;
41
+ }
42
+ /**
43
+ * A parameter-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
44
+ * by the tagged parameter.
45
+ *
46
+ * @param equivalent See {@link COMPARISON.checkAlgorithm }.
47
+ * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
48
+ * @param path See {@link DBC.decPrecondition }.
49
+ * @param hint See {@link DBC.decPrecondition }.
50
+ * @param dbc See {@link DBC.decPrecondition }.
51
+ *
52
+ * @returns See {@link DBC.decPrecondition }. */
53
+ static PRE(
54
+ // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
55
+ equivalent: any,
56
+ equalityPermitted = false,
57
+ invert = false,
58
+ path: string | undefined = undefined,
59
+ hint: string | undefined = undefined,
60
+ dbc: string | undefined = undefined,
61
+ ) {
62
+ return DBC.createPRE(
63
+ COMPARISON.checkAlgorithm,
64
+ [equivalent, equalityPermitted, invert],
65
+ dbc,
66
+ path,
67
+ hint,
68
+ );
69
+ }
70
+ /**
71
+ * A method-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
72
+ * by the tagged method's returnvalue.
73
+ *
74
+ * @param equivalent See {@link COMPARISON.checkAlgorithm }.
75
+ * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
76
+ * @param path See {@link DBC.Postcondition }.
77
+ * @param hint See {@link DBC.decPostcondition }.
78
+ * @param dbc See {@link DBC.decPostcondition }.
79
+ *
80
+ * @returns See {@link DBC.decPostcondition }. */
81
+ static POST(
82
+ // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
83
+ equivalent: any,
84
+ equalityPermitted = false,
85
+ invert = false,
86
+ path: string | undefined = undefined,
87
+ hint: string | undefined = undefined,
88
+ dbc: string | undefined = undefined,
89
+ ) {
90
+ return DBC.createPOST(
91
+ COMPARISON.checkAlgorithm,
92
+ [equivalent, equalityPermitted, invert],
93
+ dbc,
94
+ path,
95
+ hint,
96
+ );
97
+ }
98
+ /**
99
+ * A field-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
100
+ * by the tagged field.
101
+ *
102
+ * @param equivalent See {@link COMPARISON.checkAlgorithm }.
103
+ * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
104
+ * @param path See {@link DBC.decInvariant }.
105
+ * @param hint See {@link DBC.decInvariant }.
106
+ * @param dbc See {@link DBC.decInvariant }.
107
+ *
108
+ * @returns See {@link DBC.decInvariant }. */
109
+ static INVARIANT(
110
+ // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
111
+ equivalent: any,
112
+ equalityPermitted = false,
113
+ invert = false,
114
+ path: string | undefined = undefined,
115
+ hint: string | undefined = undefined,
116
+ dbc: string | undefined = undefined,
117
+ ) {
118
+ return DBC.createINVARIANT(
119
+ COMPARISON,
120
+ [equivalent, equalityPermitted, invert],
121
+ dbc,
122
+ path,
123
+ hint,
124
+ );
125
+ }
126
+ // #endregion Condition checking.
127
+ // #region Referenced Condition checking.
128
+ // #region Dynamic usage.
129
+ /**
130
+ * Invokes the {@link COMPARISON.checkAlgorithm } passing the value **toCheck**, {@link COMPARISON.equivalent } and {@link COMPARISON.invert }.
131
+ *
132
+ * @param toCheck See {@link COMPARISON.checkAlgorithm }.
133
+ *
134
+ * @returns See {@link COMPARISON.checkAlgorithm}. */
135
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic comparison
136
+ public check(toCheck: any) {
137
+ return COMPARISON.checkAlgorithm(
138
+ toCheck,
139
+ this.equivalent,
140
+ this.equalityPermitted,
141
+ this.invert,
142
+ );
143
+ }
144
+ /**
145
+ * Creates this {@link COMPARISON } by setting the protected property {@link COMPARISON.equivalent }, {@link COMPARISON.equalityPermitted } and {@link COMPARISON.invert } used by {@link COMPARISON.check }.
146
+ *
147
+ * @param equivalent See {@link COMPARISON.check }.
148
+ * @param equalityPermitted See {@link COMPARISON.check }.
149
+ * @param invert See {@link COMPARISON.check }. */
150
+ constructor(
151
+ // biome-ignore lint/suspicious/noExplicitAny: Comparison target can be any numeric value
152
+ public equivalent: any,
153
+ public equalityPermitted = false,
154
+ public invert = false,
155
+ ) {
156
+ super();
157
+ }
158
+ // #endregion Dynamic usage.
159
+ }
@@ -98,22 +98,22 @@ export class DEFINED extends DBC {
98
98
  *
99
99
  * @param toCheck See {@link DEFINED.checkAlgorithm }.
100
100
  * @param id A {@link string } identifying this {@link INSTANCE } via the {@link DBC.Infringement }-Message.
101
- *
101
+ *
102
102
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link DEFINED }.
103
- *
103
+ *
104
104
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }.*/
105
- public static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
105
+ public static tsCheck<CANDIDATE = unknown>(
106
+ toCheck: CANDIDATE | undefined | null,
107
+ hint: string | undefined = undefined,
108
+ id: string | undefined = undefined,
109
+ ): CANDIDATE {
106
110
  const result = DEFINED.checkAlgorithm(toCheck);
107
111
 
108
112
  if (result === true) {
109
113
  return toCheck as CANDIDATE;
110
114
  }
111
- else {
112
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`);
113
- }
114
- }
115
- /** Creates this {@link DEFINED }. */
116
- public constructor() {
117
- super();
115
+ throw new DBC.Infringement(
116
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
117
+ );
118
118
  }
119
119
  }
@@ -1,15 +1,15 @@
1
1
  import { EQ } from "../EQ";
2
2
  /**
3
3
  * DIFFERENT class for inequality comparisons.
4
- *
4
+ *
5
5
  * This class extends EQ and provides methods to check if a value is different (not equal)
6
6
  * from a specified equivalent value. It inverts the equality check by always passing
7
7
  * `true` for the invert parameter to the parent EQ class methods.
8
- *
8
+ *
9
9
  * @remarks
10
10
  * The class provides precondition (PRE), postcondition (POST), and invariant (INVARIANT)
11
11
  * checks for Design by Contract programming patterns.
12
- *
12
+ *
13
13
  * @see {@link COMPARISON}
14
14
  * @see {@link EQ}
15
15
  */
package/src/DBC/EQ.ts CHANGED
@@ -45,13 +45,19 @@ export class EQ extends DBC {
45
45
  invert = false,
46
46
  path: string | undefined = undefined,
47
47
  hint: string | undefined = undefined,
48
- dbc: string | undefined = undefined
48
+ dbc: string | undefined = undefined,
49
49
  ): (
50
50
  target: object,
51
51
  methodName: string | symbol,
52
52
  parameterIndex: number,
53
53
  ) => void {
54
- return DBC.createPRE(EQ.checkAlgorithm, [equivalent, invert], dbc, path, hint);
54
+ return DBC.createPRE(
55
+ EQ.checkAlgorithm,
56
+ [equivalent, invert],
57
+ dbc,
58
+ path,
59
+ hint,
60
+ );
55
61
  }
56
62
  /**
57
63
  * A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -69,13 +75,18 @@ export class EQ extends DBC {
69
75
  path: string | undefined = undefined,
70
76
  hint: string | undefined = undefined,
71
77
  dbc: string | undefined = undefined,
72
-
73
78
  ): (
74
79
  target: object,
75
80
  propertyKey: string,
76
81
  descriptor: PropertyDescriptor,
77
82
  ) => PropertyDescriptor {
78
- return DBC.createPOST(EQ.checkAlgorithm, [equivalent, invert], dbc, path, hint);
83
+ return DBC.createPOST(
84
+ EQ.checkAlgorithm,
85
+ [equivalent, invert],
86
+ dbc,
87
+ path,
88
+ hint,
89
+ );
79
90
  }
80
91
  /**
81
92
  * A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -117,17 +128,22 @@ export class EQ extends DBC {
117
128
  * @param toCheck See {@link EQ.checkAlgorithm }.
118
129
  *
119
130
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link EQ }.
120
- *
131
+ *
121
132
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link EQ }.*/
122
- public static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
133
+ public static tsCheck<CANDIDATE>(
134
+ toCheck: CANDIDATE | undefined | null,
135
+ equivalent: any,
136
+ hint: string | undefined = undefined,
137
+ id: string | undefined = undefined,
138
+ ): CANDIDATE {
123
139
  const result = EQ.checkAlgorithm(toCheck, equivalent, false);
124
140
 
125
141
  if (result) {
126
142
  return toCheck as CANDIDATE;
127
143
  }
128
- else {
129
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string} ${hint ? `✨ ${hint} ✨` : ""}`);
130
- }
144
+ throw new DBC.Infringement(
145
+ `${id ? `(${id}) ` : ""}${result as string} ${hint ? `✨ ${hint} ✨` : ""}`,
146
+ );
131
147
  }
132
148
  /**
133
149
  * Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
@@ -52,7 +52,12 @@ export class HasAttribute extends DBC {
52
52
  methodName: string | symbol,
53
53
  parameterIndex: number,
54
54
  ) => void {
55
- return DBC.createPRE(HasAttribute.checkAlgorithm, [toCheckFor, invert], dbc, path);
55
+ return DBC.createPRE(
56
+ HasAttribute.checkAlgorithm,
57
+ [toCheckFor, invert],
58
+ dbc,
59
+ path,
60
+ );
56
61
  }
57
62
  /**
58
63
  * A method-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
@@ -73,7 +78,12 @@ export class HasAttribute extends DBC {
73
78
  propertyKey: string,
74
79
  descriptor: PropertyDescriptor,
75
80
  ) => PropertyDescriptor {
76
- return DBC.createPOST(HasAttribute.checkAlgorithm, [toCheckFor, invert], dbc, path);
81
+ return DBC.createPOST(
82
+ HasAttribute.checkAlgorithm,
83
+ [toCheckFor, invert],
84
+ dbc,
85
+ path,
86
+ );
77
87
  }
78
88
  /**
79
89
  * A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
@@ -107,7 +117,11 @@ export class HasAttribute extends DBC {
107
117
  path: string | undefined = undefined,
108
118
  dbc = "WaXCode.DBC",
109
119
  ) {
110
- return DBC.decClassInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
120
+ return DBC.decClassInvariant(
121
+ [new HasAttribute(toCheckFor, invert)],
122
+ path,
123
+ dbc,
124
+ );
111
125
  }
112
126
  // #endregion Condition checking.
113
127
  // #region Referenced Condition checking.
package/src/DBC/IF.ts CHANGED
@@ -18,20 +18,30 @@ export class IF extends DBC {
18
18
  public static checkAlgorithm(
19
19
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
20
20
  toCheck: any,
21
- condition: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
21
+ condition: {
22
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
23
+ },
22
24
  inCase: {
23
25
  check: (toCheck: unknown | undefined | null | object) => boolean | string;
24
26
  },
25
- invert: boolean = false,
27
+ invert = false,
26
28
  ): boolean | string {
27
29
  if (toCheck === undefined || toCheck === null) return true;
28
30
 
29
- if (invert && condition.check(toCheck) !== true && inCase.check(toCheck) !== true) {
30
- return `In case that the value does not comply to the condition, it also has to comply to the required contract`;
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";
31
37
  }
32
38
 
33
- if (!invert && condition.check(toCheck) === true && inCase.check(toCheck) !== true) {
34
- return `In case that the value complies to the condition, it has to comply to the required contract`;
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";
35
45
  }
36
46
 
37
47
  return true;
@@ -47,18 +57,28 @@ export class IF extends DBC {
47
57
  *
48
58
  * @returns See {@link DBC.decPrecondition }. */
49
59
  public static PRE(
50
- condition: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
51
- inCase: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
60
+ condition: {
61
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
62
+ },
63
+ inCase: {
64
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
65
+ },
52
66
  path: string | undefined = undefined,
53
67
  invert = false,
54
68
  hint: string | undefined = undefined,
55
- dbc: string | undefined = undefined
69
+ dbc: string | undefined = undefined,
56
70
  ): (
57
71
  target: object,
58
72
  methodName: string | symbol,
59
73
  parameterIndex: number,
60
74
  ) => void {
61
- return DBC.createPRE(IF.checkAlgorithm, [condition, inCase, invert], dbc, path, hint);
75
+ return DBC.createPRE(
76
+ IF.checkAlgorithm,
77
+ [condition, inCase, invert],
78
+ dbc,
79
+ path,
80
+ hint,
81
+ );
62
82
  }
63
83
  /**
64
84
  * A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -71,8 +91,12 @@ export class IF extends DBC {
71
91
  *
72
92
  * @returns See {@link DBC.decPostcondition }. */
73
93
  public static POST(
74
- condition: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
75
- inCase: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
94
+ condition: {
95
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
96
+ },
97
+ inCase: {
98
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
99
+ },
76
100
  path: string | undefined = undefined,
77
101
  invert = false,
78
102
  hint: string | undefined = undefined,
@@ -82,7 +106,13 @@ export class IF extends DBC {
82
106
  propertyKey: string,
83
107
  descriptor: PropertyDescriptor,
84
108
  ) => PropertyDescriptor {
85
- return DBC.createPOST(IF.checkAlgorithm, [condition, inCase, invert], dbc, path, hint);
109
+ return DBC.createPOST(
110
+ IF.checkAlgorithm,
111
+ [condition, inCase, invert],
112
+ dbc,
113
+ path,
114
+ hint,
115
+ );
86
116
  }
87
117
  /**
88
118
  * A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -95,14 +125,24 @@ export class IF extends DBC {
95
125
  *
96
126
  * @returns See {@link DBC.decInvariant }. */
97
127
  public static INVARIANT(
98
- condition: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
99
- inCase: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
128
+ condition: {
129
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
130
+ },
131
+ inCase: {
132
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
133
+ },
100
134
  path: string | undefined = undefined,
101
135
  invert = false,
102
136
  hint: string | undefined = undefined,
103
137
  dbc: string | undefined = undefined,
104
138
  ) {
105
- return DBC.createINVARIANT(IF, [condition, inCase, invert], dbc, path, hint);
139
+ return DBC.createINVARIANT(
140
+ IF,
141
+ [condition, inCase, invert],
142
+ dbc,
143
+ path,
144
+ hint,
145
+ );
106
146
  }
107
147
  // #endregion Condition checking.
108
148
  // #region Referenced Condition checking.
@@ -125,11 +165,15 @@ export class IF extends DBC {
125
165
  * @param equivalent See {@link IF.check }. */
126
166
  public constructor(
127
167
  // biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
128
- protected condition: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
129
- protected inCase: { check: (toCheck: unknown | undefined | null | object) => boolean | string; },
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
+ },
130
174
  protected invert = false,
131
175
  ) {
132
176
  super();
133
177
  }
134
178
  // #endregion Referenced Condition checking.
135
- }
179
+ }