xdbc 1.0.98 → 1.0.100

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.
@@ -19,13 +19,13 @@ export class COMPARISON extends DBC {
19
19
  return `Value has to to be greater than or equal to "${equivalent}"`;
20
20
  }
21
21
  if (equalityPermitted && invert && toCheck > equivalent) {
22
- return `Value must not to be less than or equal to "${equivalent}"`;
22
+ return `Value has to be less than or equal to "${equivalent}"`;
23
23
  }
24
24
  if (!equalityPermitted && !invert && toCheck <= equivalent) {
25
25
  return `Value has to to be greater than "${equivalent}"`;
26
26
  }
27
27
  if (!equalityPermitted && invert && toCheck >= equivalent) {
28
- return `Value must not to be less than "${equivalent}"`;
28
+ return `Value has to be less than "${equivalent}"`;
29
29
  }
30
30
  return true;
31
31
  }
@@ -0,0 +1,81 @@
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } defining that an {@link object }s must be defined thus it's value may not be **null** or **undefined**.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
7
+ export class DEFINED extends DBC {
8
+ /**
9
+ * Checks if the value **toCheck** is null or 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
+ static checkAlgorithm(toCheck) {
16
+ // biome-ignore lint/suspicious/useValidTypeof: Necessary
17
+ if (toCheck === undefined || toCheck === null) {
18
+ return `Value may not be UNDEFINED or NULL`;
19
+ }
20
+ return true;
21
+ }
22
+ /**
23
+ * A parameter-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
24
+ * by the tagged parameter.
25
+ *
26
+ * @param type See {@link DEFINED.checkAlgorithm }.
27
+ * @param path See {@link DBC.decPrecondition }.
28
+ * @param dbc See {@link DBC.decPrecondition }.
29
+ *
30
+ * @returns See {@link DBC.decPrecondition }. */
31
+ static PRE(path = undefined, dbc = "WaXCode.DBC") {
32
+ return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
33
+ return DEFINED.checkAlgorithm(value);
34
+ }, dbc, path);
35
+ }
36
+ /**
37
+ * A method-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
38
+ * by the tagged method's returnvalue.
39
+ *
40
+ * @param type See {@link DEFINED.checkAlgorithm }.
41
+ * @param path See {@link DBC.Postcondition }.
42
+ * @param dbc See {@link DBC.decPostcondition }.
43
+ *
44
+ * @returns See {@link DBC.decPostcondition }. */
45
+ static POST(type, path = undefined, dbc = "WaXCode.DBC") {
46
+ return DBC.decPostcondition((value, target, propertyKey) => {
47
+ return DEFINED.checkAlgorithm(value);
48
+ }, dbc, path);
49
+ }
50
+ /**
51
+ * A field-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
52
+ * by the tagged field.
53
+ *
54
+ * @param type See {@link DEFINED.checkAlgorithm }.
55
+ * @param path See {@link DBC.decInvariant }.
56
+ * @param dbc See {@link DBC.decInvariant }.
57
+ *
58
+ * @returns See {@link DBC.decInvariant }. */
59
+ static INVARIANT(type, path = undefined, dbc = "WaXCode.DBC") {
60
+ return DBC.decInvariant([new DEFINED()], path, dbc);
61
+ }
62
+ // #endregion Condition checking.
63
+ // #region Referenced Condition checking.
64
+ //
65
+ // For usage in dynamic scenarios (like with AE-DBC).
66
+ //
67
+ /**
68
+ * Invokes the {@link DEFINED.checkAlgorithm } passing the value **toCheck** and the {@link DEFINED.type } .
69
+ *
70
+ * @param toCheck See {@link DEFINED.checkAlgorithm }.
71
+ *
72
+ * @returns See {@link DEFINED.checkAlgorithm}. */
73
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
74
+ check(toCheck) {
75
+ return DEFINED.checkAlgorithm(toCheck);
76
+ }
77
+ /** Creates this {@link DEFINED }. */
78
+ constructor() {
79
+ super();
80
+ }
81
+ }
@@ -0,0 +1,21 @@
1
+ import { EQ } from "../EQ";
2
+ /** See {@link COMPARISON }. */
3
+ export class DIFFERENT extends EQ {
4
+ /** See {@link COMPARISON.PRE }. */
5
+ static PRE(equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
6
+ return EQ.PRE(equivalent, true, path, dbc);
7
+ }
8
+ /** See {@link COMPARISON.POST }. */
9
+ static POST(equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
10
+ return EQ.POST(equivalent, true, path, dbc);
11
+ }
12
+ /** See {@link COMPARISON.INVARIANT }. */
13
+ static INVARIANT(equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
14
+ return EQ.INVARIANT(equivalent, true, path, dbc);
15
+ }
16
+ /** See {@link COMPARISON.constructor }. */
17
+ constructor(equivalent) {
18
+ super(equivalent, true);
19
+ this.equivalent = equivalent;
20
+ }
21
+ }
@@ -0,0 +1,108 @@
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } defining that a {@link HTMLElement } gotta have a certain attribute set.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class HasAttribute extends DBC {
8
+ // #region Condition checking.
9
+ /**
10
+ * Checks if the {@link HTMLElement } **toCheck** has the attribute **toCheckFor**.
11
+ *
12
+ * @param toCheckFor name of the attribute to check for whether it is set or not.
13
+ *
14
+ * @returns TRUE if the {@link HTMLElement } **toCheck** has set the attribute **toCheckFor**,
15
+ * otherwise a proper errormessage. */
16
+ static checkAlgorithm(
17
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
18
+ toCheck, toCheckFor, invert) {
19
+ if (!(toCheck instanceof HTMLElement)) {
20
+ return `The object to check for whether it has the attribute "${toCheckFor}" is not a HTMLElement. It is of type "${typeof toCheck}".`;
21
+ }
22
+ if (!invert && !toCheck.hasAttribute(toCheckFor)) {
23
+ return `Required Attribute "${toCheckFor}" is not set.`;
24
+ }
25
+ if (invert && toCheck.hasAttribute(toCheckFor)) {
26
+ return `Forbidden Attribute "${toCheckFor}" is set.`;
27
+ }
28
+ return true;
29
+ }
30
+ /**
31
+ * A parameter-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
32
+ * by the tagged parameter.
33
+ *
34
+ * @param toCheckFor See {@link HasAttribute.checkAlgorithm }.
35
+ * @param path See {@link DBC.decPrecondition }.
36
+ * @param dbc See {@link DBC.decPrecondition }.
37
+ *
38
+ * @returns See {@link DBC.decPrecondition }. */
39
+ static PRE(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
40
+ return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
41
+ return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
42
+ }, dbc, path);
43
+ }
44
+ /**
45
+ * A method-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
46
+ * fulfilled by the tagged method's returnvalue.
47
+ *
48
+ * @param toCheckFor See {@link HasAttribute.checkAlgorithm }.
49
+ * @param path See {@link DBC.Postcondition }.
50
+ * @param dbc See {@link DBC.decPostcondition }.
51
+ *
52
+ * @returns See {@link DBC.decPostcondition }. */
53
+ static POST(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
54
+ return DBC.decPostcondition((value, target, propertyKey) => {
55
+ return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
56
+ }, dbc, path);
57
+ }
58
+ /**
59
+ * A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
60
+ * fulfilled by the tagged field.
61
+ *
62
+ * @param toCheckFor See {@link hasAttribute.checkAlgorithm }.
63
+ * @param path See {@link DBC.decInvariant }.
64
+ * @param dbc See {@link DBC.decInvariant }.
65
+ *
66
+ * @returns See {@link DBC.decInvariant }. */
67
+ static INVARIANT(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
68
+ return DBC.decInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
69
+ }
70
+ /**
71
+ * A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
72
+ * fulfilled by the tagged field's class instance.
73
+ *
74
+ * @param toCheckFor See {@link hasAttribute.checkAlgorithm }.
75
+ * @param path See {@link DBC.decInvariant }.
76
+ * @param dbc See {@link DBC.decInvariant }.
77
+ *
78
+ * @returns See {@link DBC.decInvariant }. */
79
+ static cINVARIANT(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
80
+ return DBC.decClassInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
81
+ }
82
+ // #endregion Condition checking.
83
+ // #region Referenced Condition checking.
84
+ //
85
+ // For usage in dynamic scenarios (like with AE-DBC).
86
+ //
87
+ /**
88
+ * Invokes the {@link hasAttribute.checkAlgorithm } passing the value **toCheck**, {@link hasAttribute.equivalent } and
89
+ * {@link hasAttribute.invert }.
90
+ *
91
+ * @param toCheck See {@link EQ.checkAlgorithm }.
92
+ *
93
+ * @returns See {@link EQ.checkAlgorithm}. */
94
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
95
+ check(toCheck) {
96
+ return HasAttribute.checkAlgorithm(toCheck, this.toCheckFor, this.invert);
97
+ }
98
+ /**
99
+ * Creates this {@link DBC } by setting the protected property {@link hasAttribute.equivalent } used by
100
+ * {@link hasAttribute.check }.
101
+ *
102
+ * @param toCheckFor See {@link hasAttribute.check }. */
103
+ constructor(toCheckFor, invert = false) {
104
+ super();
105
+ this.toCheckFor = toCheckFor;
106
+ this.invert = invert;
107
+ }
108
+ }
package/dist/DBC/IF.js ADDED
@@ -0,0 +1,99 @@
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
+ static checkAlgorithm(
19
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
20
+ toCheck, condition, inCase, invert) {
21
+ if (!invert && condition.check(toCheck) && !inCase.check(toCheck)) {
22
+ return `In case that the value complies to "${condition}" it also has to comply to "${inCase}"`;
23
+ }
24
+ if (!invert && !condition.check(toCheck) && !inCase.check(toCheck)) {
25
+ return `In case that the value does not comply to "${condition}" it has to comply to "${inCase}"`;
26
+ }
27
+ return true;
28
+ }
29
+ /**
30
+ * A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
31
+ * by the tagged parameter.
32
+ *
33
+ * @param condition See {@link IF.checkAlgorithm }.
34
+ * @param inCase See {@link IF.checkAlgorithm }.
35
+ * @param path See {@link DBC.decPrecondition }.
36
+ * @param dbc See {@link DBC.decPrecondition }.
37
+ *
38
+ * @returns See {@link DBC.decPrecondition }. */
39
+ static PRE(condition, inCase, invert = false, path = undefined, dbc = "WaXCode.DBC") {
40
+ return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
41
+ return IF.checkAlgorithm(value, condition, inCase, invert);
42
+ }, dbc, path);
43
+ }
44
+ /**
45
+ * A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
46
+ * by the tagged method's returnvalue.
47
+ *
48
+ * @param condition See {@link IF.checkAlgorithm }.
49
+ * @param inCase See {@link IF.checkAlgorithm }.
50
+ * @param path See {@link DBC.Postcondition }.
51
+ * @param dbc See {@link DBC.decPostcondition }.
52
+ *
53
+ * @returns See {@link DBC.decPostcondition }. */
54
+ static POST(condition, inCase, invert = false, path = undefined, dbc = "WaXCode.DBC") {
55
+ return DBC.decPostcondition((value, target, propertyKey) => {
56
+ return IF.checkAlgorithm(value, condition, inCase, invert);
57
+ }, dbc, path);
58
+ }
59
+ /**
60
+ * A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
61
+ * by the tagged field.
62
+ *
63
+ * @param condition See {@link IF.checkAlgorithm }.
64
+ * @param inCase See {@link IF.checkAlgorithm }.
65
+ * @param path See {@link DBC.decInvariant }.
66
+ * @param dbc See {@link DBC.decInvariant }.
67
+ *
68
+ * @returns See {@link DBC.decInvariant }. */
69
+ static INVARIANT(condition, inCase, invert = false, path = undefined, dbc = "WaXCode.DBC") {
70
+ return DBC.decInvariant([new IF(condition, inCase, invert)], path, dbc);
71
+ }
72
+ // #endregion Condition checking.
73
+ // #region Referenced Condition checking.
74
+ //
75
+ // For usage in dynamic scenarios (like with AE-DBC).
76
+ //
77
+ /**
78
+ * Invokes the {@link IF.checkAlgorithm } passing the value **toCheck**, {@link IF.equivalent } and {@link IF.invert }.
79
+ *
80
+ * @param toCheck See {@link IF.checkAlgorithm }.
81
+ *
82
+ * @returns See {@link IF.checkAlgorithm}. */
83
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
84
+ check(toCheck) {
85
+ return IF.checkAlgorithm(toCheck, this.condition, this.inCase, this.invert);
86
+ }
87
+ /**
88
+ * Creates this {@link IF } by setting the protected property {@link IF.equivalent } used by {@link IF.check }.
89
+ *
90
+ * @param equivalent See {@link IF.check }. */
91
+ constructor(
92
+ // biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
93
+ condition, inCase, invert = false) {
94
+ super();
95
+ this.condition = condition;
96
+ this.inCase = inCase;
97
+ this.invert = invert;
98
+ }
99
+ }
@@ -81,6 +81,20 @@ export class INSTANCE extends DBC {
81
81
  check(toCheck) {
82
82
  return INSTANCE.checkAlgorithm(toCheck, this.reference);
83
83
  }
84
+ /**
85
+ *
86
+ * @param toCheck
87
+ * @returns
88
+ */
89
+ tsCheck(toCheck) {
90
+ const result = INSTANCE.checkAlgorithm(toCheck, this.reference);
91
+ if (result) {
92
+ return toCheck;
93
+ }
94
+ else {
95
+ throw new DBC.Infringement(result);
96
+ }
97
+ }
84
98
  /**
85
99
  * Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
86
100
  *
package/dist/DBC.js CHANGED
@@ -94,6 +94,63 @@ export class DBC {
94
94
  return descriptor;
95
95
  }
96
96
  // #endregion Parameter-value requests.
97
+ // #region Class
98
+ /**
99
+ * A property-decorator factory serving as a **D**esign **B**y **C**ontract Invariant.
100
+ * This invariant aims to check the instance of the class not the value to be get or set.
101
+ *
102
+ * @param contracts The {@link DBC }-Contracts the value shall uphold.
103
+ *
104
+ * @throws A {@link DBC.Infringement } whenever the property is tried to be get or set without the instance of it's class
105
+ * fulfilling the specified **contracts**. */
106
+ static decClassInvariant(contracts, path = undefined, dbc = "WaXCode.DBC") {
107
+ return (target, propertyKey, descriptor) => {
108
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants) {
109
+ return;
110
+ }
111
+ const originalSetter = descriptor.set;
112
+ const originalGetter = descriptor.get;
113
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary to intercept UNDEFINED and NULL.
114
+ let value;
115
+ // #region Replace original property.
116
+ Object.defineProperty(target, propertyKey, {
117
+ get() {
118
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants) {
119
+ return;
120
+ }
121
+ const realValue = path ? DBC.resolve(this, path) : this;
122
+ // #region Check if all "contracts" are fulfilled.
123
+ for (const contract of contracts) {
124
+ const result = contract.check(realValue);
125
+ if (typeof result === "string") {
126
+ DBC.resolveDBCPath(window, dbc).reportFieldInfringement(result, target, path, propertyKey, realValue);
127
+ }
128
+ }
129
+ // #endregion Check if all "contracts" are fulfilled.
130
+ return originalGetter[propertyKey];
131
+ },
132
+ set(newValue) {
133
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants) {
134
+ return;
135
+ }
136
+ const realValue = path ? DBC.resolve(this, path) : this;
137
+ // #region Check if all "contracts" are fulfilled.
138
+ for (const contract of contracts) {
139
+ const result = contract.check(realValue);
140
+ if (typeof result === "string") {
141
+ DBC.resolveDBCPath(window, dbc).reportFieldInfringement(result, target, path, propertyKey, realValue);
142
+ }
143
+ }
144
+ // #endregion Check if all "contracts" are fulfilled.
145
+ value = newValue;
146
+ },
147
+ enumerable: true,
148
+ configurable: true,
149
+ });
150
+ // #endregion Replace original property.
151
+ };
152
+ }
153
+ // #endregion Class
97
154
  // #region Invariant
98
155
  /**
99
156
  * A property-decorator factory serving as a **D**esign **B**y **C**ontract Invariant.
@@ -106,11 +163,17 @@ export class DBC {
106
163
  * specified **contracts**, by the returned method.*/
107
164
  static decInvariant(contracts, path = undefined, dbc = "WaXCode.DBC") {
108
165
  return (target, propertyKey) => {
166
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants) {
167
+ return;
168
+ }
109
169
  // biome-ignore lint/suspicious/noExplicitAny: Necessary to intercept UNDEFINED and NULL.
110
170
  let value;
111
171
  // #region Replace original property.
112
172
  Object.defineProperty(target, propertyKey, {
113
173
  set(newValue) {
174
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants) {
175
+ return;
176
+ }
114
177
  const realValue = path ? DBC.resolve(newValue, path) : newValue;
115
178
  // #region Check if all "contracts" are fulfilled.
116
179
  for (const contract of contracts) {
@@ -147,6 +210,9 @@ export class DBC {
147
210
  const originalMethod = descriptor.value;
148
211
  // biome-ignore lint/suspicious/noExplicitAny: Necessary to intercept UNDEFINED and NULL.
149
212
  descriptor.value = (...args) => {
213
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkPostconditions) {
214
+ return;
215
+ }
150
216
  // biome-ignore lint/complexity/noThisInStatic: <explanation>
151
217
  const result = originalMethod.apply(this, args);
152
218
  const realValue = path ? DBC.resolve(result, path) : result;
@@ -175,6 +241,10 @@ export class DBC {
175
241
  static decPrecondition(check, dbc, path = undefined) {
176
242
  return (target, methodName, parameterIndex) => {
177
243
  DBC.requestParamValue(target, methodName, parameterIndex, (value) => {
244
+ if (!DBC.resolveDBCPath(window, dbc).executionSettings
245
+ .checkPreconditions) {
246
+ return;
247
+ }
178
248
  const realValue = path ? DBC.resolve(value, path) : value;
179
249
  const result = check(realValue, target, methodName, parameterIndex);
180
250
  if (typeof result === "string") {
@@ -247,10 +317,23 @@ export class DBC {
247
317
  * Constructs this {@link DBC } by setting the {@link DBC.infringementSettings }, define the **WaXCode** namespace in
248
318
  * **window** if not yet available and setting the property **DBC** in there to the instance of this {@link DBC }.
249
319
  *
250
- * @param infringementSettings See {@link DBC.infringementSettings }. */
251
- constructor(infringementSettings = { throwException: true, logToConsole: false }) {
320
+ * @param infringementSettings See {@link DBC.infringementSettings }.
321
+ * @param executionSettings See {@link DBC.executionSettings }. */
322
+ constructor(infringementSettings = { throwException: true, logToConsole: false }, executionSettings = {
323
+ checkPreconditions: true,
324
+ checkPostconditions: true,
325
+ checkInvariants: true,
326
+ }) {
252
327
  // #endregion Precondition
253
328
  // #endregion Decorator
329
+ // #region Execution Handling
330
+ /** Stores settings concerning the execution of checks. */
331
+ this.executionSettings = {
332
+ checkPreconditions: true,
333
+ checkPostconditions: true,
334
+ checkInvariants: true,
335
+ };
336
+ // #endregion Execution Handling
254
337
  // #region Warning handling.
255
338
  /** Stores settings concerning warnings. */
256
339
  this.warningSettings = { logToConsole: true };
package/dist/Demo.js CHANGED
@@ -17,6 +17,10 @@ import { TYPE } from "./DBC/TYPE";
17
17
  import { AE } from "./DBC/AE";
18
18
  import { INSTANCE } from "./DBC/INSTANCE";
19
19
  import { GREATER } from "./DBC/COMPARISON/GREATER";
20
+ import { GREATER_OR_EQUAL } from "./DBC/COMPARISON/GREATER_OR_EQUAL";
21
+ import { LESS } from "./DBC/COMPARISON/LESS";
22
+ import { LESS_OR_EQUAL } from "./DBC/COMPARISON/LESS_OR_EQUAL";
23
+ import { DIFFERENT } from "./DBC/EQ/DIFFERENT";
20
24
  /** Demonstrative use of **D**esign **B**y **C**ontract Decorators */
21
25
  export class Demo {
22
26
  constructor() {
@@ -61,6 +65,10 @@ export class Demo {
61
65
  // #endregion Check AE Index
62
66
  // #region Check Comparison
63
67
  testGREATER(input) { }
68
+ testGREATER_OR_EQUAL(input) { }
69
+ testLESS(input) { }
70
+ testLESS_OR_EQUAL(input) { }
71
+ testDIFFERENT(input) { }
64
72
  }
65
73
  __decorate([
66
74
  REGEX.INVARIANT(/^a$/),
@@ -139,11 +147,40 @@ __decorate([
139
147
  __metadata("design:returntype", void 0)
140
148
  ], Demo.prototype, "testAEIndex", null);
141
149
  __decorate([
150
+ DBC.ParamvalueProvider,
142
151
  __param(0, GREATER.PRE(2)),
143
152
  __metadata("design:type", Function),
144
153
  __metadata("design:paramtypes", [Number]),
145
154
  __metadata("design:returntype", void 0)
146
155
  ], Demo.prototype, "testGREATER", null);
156
+ __decorate([
157
+ DBC.ParamvalueProvider,
158
+ __param(0, GREATER_OR_EQUAL.PRE(2)),
159
+ __metadata("design:type", Function),
160
+ __metadata("design:paramtypes", [Number]),
161
+ __metadata("design:returntype", void 0)
162
+ ], Demo.prototype, "testGREATER_OR_EQUAL", null);
163
+ __decorate([
164
+ DBC.ParamvalueProvider,
165
+ __param(0, LESS.PRE(20)),
166
+ __metadata("design:type", Function),
167
+ __metadata("design:paramtypes", [Number]),
168
+ __metadata("design:returntype", void 0)
169
+ ], Demo.prototype, "testLESS", null);
170
+ __decorate([
171
+ DBC.ParamvalueProvider,
172
+ __param(0, LESS_OR_EQUAL.PRE(20)),
173
+ __metadata("design:type", Function),
174
+ __metadata("design:paramtypes", [Number]),
175
+ __metadata("design:returntype", void 0)
176
+ ], Demo.prototype, "testLESS_OR_EQUAL", null);
177
+ __decorate([
178
+ DBC.ParamvalueProvider,
179
+ __param(0, DIFFERENT.PRE(20)),
180
+ __metadata("design:type", Function),
181
+ __metadata("design:paramtypes", [Number]),
182
+ __metadata("design:returntype", void 0)
183
+ ], Demo.prototype, "testDIFFERENT", null);
147
184
  const demo = new Demo();
148
185
  try {
149
186
  demo.testProperty = "abd";
@@ -152,16 +189,16 @@ catch (X) {
152
189
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
153
190
  console.log("INVARIANT Infringement", "OK");
154
191
  console.log(X);
155
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
192
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
156
193
  }
157
194
  demo.testProperty = "a";
158
195
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
159
196
  console.log("INVARIANT OK");
160
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
197
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
161
198
  demo.testParamvalueAndReturnvalue("holla");
162
199
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
163
200
  console.log("PARAMETER- & RETURNVALUE OK");
164
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
201
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
165
202
  try {
166
203
  demo.testParamvalueAndReturnvalue("yyyy");
167
204
  }
@@ -169,12 +206,12 @@ catch (X) {
169
206
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
170
207
  console.log("PARAMETER- & RETURNVALUE Infringement", "OK");
171
208
  console.log(X);
172
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
209
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
173
210
  }
174
211
  demo.testReturnvalue("xxxx");
175
212
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
176
213
  console.log("RETURNVALUE OK");
177
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
214
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
178
215
  try {
179
216
  demo.testReturnvalue("yyyy");
180
217
  }
@@ -182,12 +219,12 @@ catch (X) {
182
219
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
183
220
  console.log("RETURNVALUE Infringement", "OK");
184
221
  console.log(X);
185
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
222
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
186
223
  }
187
224
  demo.testEQAndPath(document.createElement("select"));
188
225
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
189
226
  console.log("EQ with Path Infringement OK");
190
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
227
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
191
228
  try {
192
229
  demo.testEQAndPathWithInversion(document.createElement("select"));
193
230
  }
@@ -195,12 +232,12 @@ catch (X) {
195
232
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
196
233
  console.log("EQ with Path and Inversion Infringement OK");
197
234
  console.log(X);
198
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
235
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
199
236
  }
200
237
  demo.testTYPE("x");
201
238
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
202
239
  console.log("TYPE OK");
203
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
240
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
204
241
  try {
205
242
  demo.testTYPE(0);
206
243
  }
@@ -208,12 +245,12 @@ catch (X) {
208
245
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
209
246
  console.log("TYPE Infringement OK");
210
247
  console.log(X);
211
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
248
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
212
249
  }
213
250
  demo.testAE(["11", "10", "b"]);
214
251
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
215
252
  console.log("AE OK");
216
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
253
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
217
254
  try {
218
255
  demo.testAE(["11", 11, "b"]);
219
256
  }
@@ -221,12 +258,12 @@ catch (X) {
221
258
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
222
259
  console.log("AE Infringement OK");
223
260
  console.log(X);
224
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
261
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
225
262
  }
226
263
  demo.testREGEXWithAE(["+1d", "NOW", "-10y"]);
227
264
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
228
265
  console.log("REGEX with AE OK");
229
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
266
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
230
267
  try {
231
268
  demo.testREGEXWithAE(["+1d", "+5d", "-x10y"]);
232
269
  }
@@ -234,12 +271,12 @@ catch (X) {
234
271
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
235
272
  console.log("REGEX with AE Infringement OK");
236
273
  console.log(X);
237
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
274
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
238
275
  }
239
276
  demo.testINSTANCE(new Date());
240
277
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
241
278
  console.log("INSTANCE OK");
242
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
279
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
243
280
  try {
244
281
  demo.testINSTANCE(demo);
245
282
  }
@@ -247,12 +284,12 @@ catch (X) {
247
284
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
248
285
  console.log("INSTANCE Infringement OK");
249
286
  console.log(X);
250
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
287
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
251
288
  }
252
289
  demo.testAERange([11, "abc", "abc"]);
253
290
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
254
291
  console.log("AE Range OK");
255
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
292
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
256
293
  try {
257
294
  demo.testAERange([11, "abc", /a/g]);
258
295
  }
@@ -260,12 +297,12 @@ catch (X) {
260
297
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
261
298
  console.log("AE Range Infringement OK");
262
299
  console.log(X);
263
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
300
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
264
301
  }
265
302
  demo.testAEIndex([11, "abc", "abc"]);
266
303
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
267
304
  console.log("AE Index OK");
268
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
305
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
269
306
  try {
270
307
  demo.testAEIndex(["11", 12, "/a/g"]);
271
308
  }
@@ -273,18 +310,111 @@ catch (X) {
273
310
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
274
311
  console.log("AE Index Infringement OK");
275
312
  console.log(X);
276
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
313
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
277
314
  }
278
315
  demo.testGREATER(11);
279
316
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
280
317
  console.log("GREATER OK");
281
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
318
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
282
319
  try {
283
320
  demo.testGREATER(2);
284
321
  }
285
322
  catch (X) {
286
323
  console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
287
- console.log("GREATER OK");
324
+ console.log("GREATER Infringement OK");
325
+ console.log(X);
326
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
327
+ }
328
+ demo.testGREATER_OR_EQUAL(2);
329
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
330
+ console.log("GREATER_OR_EQUAL OK");
331
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
332
+ try {
333
+ demo.testGREATER_OR_EQUAL(1);
334
+ }
335
+ catch (X) {
336
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
337
+ console.log("GREATER_OR_EQUAL Infringement OK");
338
+ console.log(X);
339
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
340
+ }
341
+ demo.testLESS(10);
342
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
343
+ console.log("LESS OK");
344
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
345
+ try {
346
+ demo.testLESS(20);
347
+ }
348
+ catch (X) {
349
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
350
+ console.log("LESS Infringement OK");
351
+ console.log(X);
352
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
353
+ }
354
+ demo.testLESS_OR_EQUAL(20);
355
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
356
+ console.log("LESS OK");
357
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
358
+ try {
359
+ demo.testLESS_OR_EQUAL(21);
360
+ }
361
+ catch (X) {
362
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
363
+ console.log("LESS_OR_EQUAL Infringement OK");
364
+ console.log(X);
365
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
366
+ }
367
+ demo.testDIFFERENT(21);
368
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
369
+ console.log("DIFFERENT OK");
370
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
371
+ try {
372
+ demo.testDIFFERENT(20);
373
+ }
374
+ catch (X) {
375
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
376
+ console.log("DIFFERENT Infringement OK");
377
+ console.log(X);
378
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
379
+ }
380
+ // #region Inactivity Checks
381
+ window.WaXCode.DBC.executionSettings.checkPreconditions = false;
382
+ try {
383
+ demo.testLESS_OR_EQUAL(21);
384
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
385
+ console.log("INACTIVE PRECONDITIONS OK");
386
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
387
+ }
388
+ catch (X) {
389
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
390
+ console.log("INACTIVE PRECONDITIONS FAILED");
391
+ console.log(X);
392
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
393
+ }
394
+ window.WaXCode.DBC.executionSettings.checkPostconditions = false;
395
+ try {
396
+ demo.testReturnvalue("qqqqq");
397
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
398
+ console.log("INACTIVE POSTCONDITIONS OK");
399
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
400
+ }
401
+ catch (X) {
402
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
403
+ console.log("INACTIVE POSTCONDITIONS FAILED");
404
+ console.log(X);
405
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
406
+ }
407
+ window.WaXCode.DBC.executionSettings.checkInvariants = false;
408
+ try {
409
+ demo.testProperty = "b";
410
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
411
+ console.log("INACTIVE INVARIANTS OK");
412
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
413
+ }
414
+ catch (X) {
415
+ console.log("⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄");
416
+ console.log("INACTIVE INVARIANTS FAILED");
288
417
  console.log(X);
289
- console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
418
+ console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
290
419
  }
420
+ // #endregion Inactivity Checks
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.98",
2
+ "version": "1.0.100",
3
3
  "name": "xdbc",
4
4
  "scripts": {
5
5
  "docs": "typedoc",
@@ -0,0 +1,114 @@
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } defining that an {@link object }s must be defined thus it's value may not be **null** or **undefined**.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
7
+ export class DEFINED extends DBC {
8
+ /**
9
+ * Checks if the value **toCheck** is null or 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 || toCheck === null ) {
18
+ return `Value may not be UNDEFINED or NULL`;
19
+ }
20
+
21
+ return true;
22
+ }
23
+ /**
24
+ * A parameter-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
25
+ * by the tagged parameter.
26
+ *
27
+ * @param type See {@link DEFINED.checkAlgorithm }.
28
+ * @param path See {@link DBC.decPrecondition }.
29
+ * @param dbc See {@link DBC.decPrecondition }.
30
+ *
31
+ * @returns See {@link DBC.decPrecondition }. */
32
+ public static PRE(
33
+ path: string | undefined = undefined,
34
+ dbc = "WaXCode.DBC",
35
+ ): (
36
+ target: object,
37
+ methodName: string | symbol,
38
+ parameterIndex: number,
39
+ ) => void {
40
+ return DBC.decPrecondition(
41
+ (
42
+ value: object,
43
+ target: object,
44
+ methodName: string,
45
+ parameterIndex: number,
46
+ ) => {
47
+ return DEFINED.checkAlgorithm(value);
48
+ },
49
+ dbc,
50
+ path,
51
+ );
52
+ }
53
+ /**
54
+ * A method-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
55
+ * by the tagged method's returnvalue.
56
+ *
57
+ * @param type See {@link DEFINED.checkAlgorithm }.
58
+ * @param path See {@link DBC.Postcondition }.
59
+ * @param dbc See {@link DBC.decPostcondition }.
60
+ *
61
+ * @returns See {@link DBC.decPostcondition }. */
62
+ public static POST(
63
+ type: string,
64
+ path: string | undefined = undefined,
65
+ dbc = "WaXCode.DBC",
66
+ ): (
67
+ target: object,
68
+ propertyKey: string,
69
+ descriptor: PropertyDescriptor,
70
+ ) => PropertyDescriptor {
71
+ return DBC.decPostcondition(
72
+ (value: object, target: object, propertyKey: string) => {
73
+ return DEFINED.checkAlgorithm(value);
74
+ },
75
+ dbc,
76
+ path,
77
+ );
78
+ }
79
+ /**
80
+ * A field-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
81
+ * by the tagged field.
82
+ *
83
+ * @param type See {@link DEFINED.checkAlgorithm }.
84
+ * @param path See {@link DBC.decInvariant }.
85
+ * @param dbc See {@link DBC.decInvariant }.
86
+ *
87
+ * @returns See {@link DBC.decInvariant }. */
88
+ public static INVARIANT(
89
+ type: string,
90
+ path: string | undefined = undefined,
91
+ dbc = "WaXCode.DBC",
92
+ ) {
93
+ return DBC.decInvariant([new DEFINED()], path, dbc);
94
+ }
95
+ // #endregion Condition checking.
96
+ // #region Referenced Condition checking.
97
+ //
98
+ // For usage in dynamic scenarios (like with AE-DBC).
99
+ //
100
+ /**
101
+ * Invokes the {@link DEFINED.checkAlgorithm } passing the value **toCheck** and the {@link DEFINED.type } .
102
+ *
103
+ * @param toCheck See {@link DEFINED.checkAlgorithm }.
104
+ *
105
+ * @returns See {@link DEFINED.checkAlgorithm}. */
106
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
107
+ public check(toCheck: any) {
108
+ return DEFINED.checkAlgorithm(toCheck);
109
+ }
110
+ /** Creates this {@link DEFINED }. */
111
+ public constructor() {
112
+ super();
113
+ }
114
+ }
@@ -4,7 +4,7 @@ import { DBC } from "../DBC";
4
4
  *
5
5
  * @remarks
6
6
  * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
7
- export class INSTANCE extends DBC {
7
+ export class INSTANCE < CANDIDATE = any > extends DBC {
8
8
  /**
9
9
  * Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
10
10
  *
@@ -112,6 +112,21 @@ export class INSTANCE extends DBC {
112
112
  public check(toCheck: any) {
113
113
  return INSTANCE.checkAlgorithm(toCheck, this.reference);
114
114
  }
115
+ /**
116
+ *
117
+ * @param toCheck
118
+ * @returns
119
+ */
120
+ public tsCheck( toCheck : any ) : CANDIDATE {
121
+ const result = INSTANCE.checkAlgorithm(toCheck, this.reference);
122
+
123
+ if( result ) {
124
+ return toCheck ;
125
+ }
126
+ else {
127
+ throw new DBC.Infringement( result as string );
128
+ }
129
+ }
115
130
  /**
116
131
  * Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
117
132
  *