xdbc 1.0.207 → 1.0.209

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 (75) hide show
  1. package/Assessment.html +350 -0
  2. package/Assessment.md +507 -51
  3. package/CHANGELOG.md +55 -0
  4. package/CONTRIBUTING.md +129 -17
  5. package/README.md +373 -71
  6. package/SECURITY.md +60 -18
  7. package/SUPPORT.md +65 -0
  8. package/__tests__/DBC/DEFINED.test.ts +53 -0
  9. package/__tests__/DBC/Decorators.test.ts +365 -0
  10. package/__tests__/DBC/GREATER.test.ts +8 -6
  11. package/__tests__/DBC/HasAttribute.test.ts +56 -0
  12. package/__tests__/DBC/IF.test.ts +52 -0
  13. package/__tests__/DBC/JSON.Parse.test.ts +1 -1
  14. package/__tests__/DBC/OR.test.ts +1 -1
  15. package/__tests__/DBC/REGEX.test.ts +1 -1
  16. package/__tests__/DBC/TYPE.test.ts +1 -1
  17. package/__tests__/DBC/UNDEFINED.test.ts +45 -0
  18. package/__tests__/DBC/ZOD.test.ts +54 -0
  19. package/jest.config.js +21 -0
  20. package/package.json +4 -5
  21. package/src/DBC/AE.ts +10 -6
  22. package/src/DBC/COMPARISON/GREATER.ts +11 -7
  23. package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +14 -10
  24. package/src/DBC/COMPARISON/LESS.ts +14 -10
  25. package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +14 -10
  26. package/src/DBC/COMPARISON.ts +20 -43
  27. package/src/DBC/DEFINED.ts +4 -23
  28. package/src/DBC/EQ/DIFFERENT.ts +21 -56
  29. package/src/DBC/EQ.ts +7 -26
  30. package/src/DBC/HasAttribute.ts +9 -26
  31. package/src/DBC/IF.ts +8 -27
  32. package/src/DBC/INSTANCE.ts +5 -22
  33. package/src/DBC/JSON.OP.ts +4 -34
  34. package/src/DBC/JSON.Parse.ts +5 -25
  35. package/src/DBC/OR.ts +5 -14
  36. package/src/DBC/REGEX.ts +41 -40
  37. package/src/DBC/TYPE.ts +6 -25
  38. package/src/DBC/UNDEFINED.ts +3 -22
  39. package/src/DBC/ZOD.ts +10 -27
  40. package/src/DBC.ts +223 -55
  41. package/tsconfig.json +7 -4
  42. package/tsconfig.test.json +12 -0
  43. package/.parcel-cache/bf96c58b6061a62a-BundleGraph +0 -0
  44. package/.parcel-cache/d7c812d65aeeac59-AssetGraph +0 -0
  45. package/.parcel-cache/data.mdb +0 -0
  46. package/.parcel-cache/e81759c1f106a17f-RequestGraph +0 -0
  47. package/.parcel-cache/fe0db3c4eb428be2-AssetGraph +0 -0
  48. package/.parcel-cache/lock.mdb +0 -0
  49. package/.parcel-cache/snapshot-e81759c1f106a17f.txt +0 -4609
  50. package/dist/DBC/AE.js +0 -173
  51. package/dist/DBC/COMPARISON/GREATER.js +0 -21
  52. package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +0 -21
  53. package/dist/DBC/COMPARISON/LESS.js +0 -21
  54. package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +0 -21
  55. package/dist/DBC/COMPARISON.js +0 -99
  56. package/dist/DBC/DEFINED.js +0 -99
  57. package/dist/DBC/EQ/DIFFERENT.js +0 -21
  58. package/dist/DBC/EQ.js +0 -100
  59. package/dist/DBC/GREATER.js +0 -99
  60. package/dist/DBC/HasAttribute.js +0 -108
  61. package/dist/DBC/IF.js +0 -99
  62. package/dist/DBC/INSTANCE.js +0 -93
  63. package/dist/DBC/JSON.OP.js +0 -133
  64. package/dist/DBC/JSON.Parse.js +0 -114
  65. package/dist/DBC/OR.js +0 -113
  66. package/dist/DBC/REGEX.js +0 -110
  67. package/dist/DBC/TYPE.js +0 -87
  68. package/dist/DBC/ZOD.js +0 -114
  69. package/dist/DBC.js +0 -336
  70. package/dist/Demo.js +0 -290
  71. package/dist/Test.html +0 -18
  72. package/dist/bundle.js +0 -2064
  73. package/dist/index.html +0 -18
  74. package/jest.config.ts +0 -20
  75. package/xpackage-lock.json +0 -122
@@ -38,19 +38,7 @@ export class DEFINED extends DBC {
38
38
  methodName: string | symbol,
39
39
  parameterIndex: number,
40
40
  ) => void {
41
- return DBC.decPrecondition(
42
- (
43
- value: object,
44
- target: object,
45
- methodName: string,
46
- parameterIndex: number,
47
- ) => {
48
- return DEFINED.checkAlgorithm(value);
49
- },
50
- dbc,
51
- path,
52
- hint
53
- );
41
+ return DBC.createPRE(DEFINED.checkAlgorithm, [], dbc, path, hint);
54
42
  }
55
43
  /**
56
44
  * A method-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -71,14 +59,7 @@ export class DEFINED extends DBC {
71
59
  propertyKey: string,
72
60
  descriptor: PropertyDescriptor,
73
61
  ) => PropertyDescriptor {
74
- return DBC.decPostcondition(
75
- (value: object, target: object, propertyKey: string) => {
76
- return DEFINED.checkAlgorithm(value);
77
- },
78
- dbc,
79
- path,
80
- hint
81
- );
62
+ return DBC.createPOST(DEFINED.checkAlgorithm, [], dbc, path, hint);
82
63
  }
83
64
  /**
84
65
  * A field-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -95,7 +76,7 @@ export class DEFINED extends DBC {
95
76
  hint: string | undefined = undefined,
96
77
  dbc: string | undefined = undefined,
97
78
  ) {
98
- return DBC.decInvariant([new DEFINED()], path, dbc, hint);
79
+ return DBC.createINVARIANT(DEFINED, [], dbc, path, hint);
99
80
  }
100
81
  // #endregion Condition checking.
101
82
  // #region Referenced Condition checking.
@@ -121,7 +102,7 @@ export class DEFINED extends DBC {
121
102
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link DEFINED }.
122
103
  *
123
104
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }.*/
124
- public static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
105
+ public static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
125
106
  const result = DEFINED.checkAlgorithm(toCheck);
126
107
 
127
108
  if (result === true) {
@@ -14,79 +14,44 @@ import { EQ } from "../EQ";
14
14
  * @see {@link EQ}
15
15
  */
16
16
  export class DIFFERENT extends EQ {
17
- /**
18
- * Precondition overload signature.
19
- * @param equivalent - The value to compare for inequality
20
- * @param path - The property path
21
- * @param hint - Optional hint message
22
- */
23
- public static override PRE(
24
- equivalent,
25
- path,
26
- hint
27
- );
28
- /**
29
- * Precondition overload signature.
30
- * @param equivalent - The value to compare for inequality
31
- * @param path - The property path
32
- */
17
+ /** See {@link EQ.PRE }. Always inverts equality check. */
18
+ // biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
33
19
  public static override PRE(
34
- equivalent,
35
- path,
36
- );
37
- /** See {@link COMPARISON.PRE }. */
38
- public static override PRE(
39
- equivalent,
40
- invert: boolean = false,
41
- path: string = undefined,
20
+ equivalent: any,
21
+ _invert = false,
22
+ path: string | undefined = undefined,
42
23
  hint: string | undefined = undefined,
43
24
  dbc: string | undefined = undefined,
44
25
  ) {
45
- return EQ.PRE(equivalent, true, path, dbc, hint);
26
+ return EQ.PRE(equivalent, true, path, hint, dbc);
46
27
  }
47
28
 
29
+ /** See {@link EQ.POST }. Always inverts equality check. */
30
+ // biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
48
31
  public static override POST(
49
- equivalent,
50
- path,
51
- hint
52
- );
53
- public static override POST(
54
- equivalent,
55
- path,
56
- );
57
-
58
- /** See {@link COMPARISON.POST }. */
59
- public static override POST(
60
- equivalent,
61
- invert = false,
62
- path: string = undefined,
32
+ equivalent: any,
33
+ _invert = false,
34
+ path: string | undefined = undefined,
63
35
  hint: string | undefined = undefined,
64
36
  dbc: string | undefined = undefined,
65
37
  ) {
66
- return EQ.POST(equivalent, true, path, dbc, hint);
38
+ return EQ.POST(equivalent, true, path, hint, dbc);
67
39
  }
68
- public static override INVARIANT(
69
- equivalent,
70
- path,
71
- hint
72
- );
73
- public static override INVARIANT(
74
- equivalent,
75
- path,
76
- );
77
40
 
78
- /** See {@link COMPARISON.INVARIANT }. */
41
+ /** See {@link EQ.INVARIANT }. Always inverts equality check. */
42
+ // biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
79
43
  public static INVARIANT(
80
- equivalent,
81
- invert = false,
82
- path: string = undefined,
44
+ equivalent: any,
45
+ _invert = false,
46
+ path: string | undefined = undefined,
83
47
  hint: string | undefined = undefined,
84
48
  dbc: string | undefined = undefined,
85
49
  ) {
86
- return EQ.INVARIANT(equivalent, true, path, dbc, hint);
50
+ return EQ.INVARIANT(equivalent, true, path, hint, dbc);
87
51
  }
88
- /** See {@link COMPARISON.constructor }. */
89
- constructor(public equivalent) {
52
+ /** See {@link EQ.constructor }. */
53
+ // biome-ignore lint/suspicious/noExplicitAny: Must match parent signature
54
+ constructor(public equivalent: any) {
90
55
  super(equivalent, true);
91
56
  }
92
57
  }
package/src/DBC/EQ.ts CHANGED
@@ -18,14 +18,14 @@ export class EQ extends DBC {
18
18
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
19
19
  toCheck: any,
20
20
  equivalent: object,
21
- invert,
21
+ invert: boolean,
22
22
  ): boolean | string {
23
23
  if (!invert && equivalent !== toCheck) {
24
- return `Value has to to be equal to "${equivalent}"`;
24
+ return `Value has to be equal to "${equivalent}"`;
25
25
  }
26
26
 
27
27
  if (invert && equivalent === toCheck) {
28
- return `Value must not to be equal to "${equivalent}"`;
28
+ return `Value must not be equal to "${equivalent}"`;
29
29
  }
30
30
 
31
31
  return true;
@@ -51,19 +51,7 @@ export class EQ extends DBC {
51
51
  methodName: string | symbol,
52
52
  parameterIndex: number,
53
53
  ) => void {
54
- return DBC.decPrecondition(
55
- (
56
- value: object,
57
- target: object,
58
- methodName: string,
59
- parameterIndex: number,
60
- ) => {
61
- return EQ.checkAlgorithm(value, equivalent, invert);
62
- },
63
- dbc,
64
- path,
65
- hint
66
- );
54
+ return DBC.createPRE(EQ.checkAlgorithm, [equivalent, invert], dbc, path, hint);
67
55
  }
68
56
  /**
69
57
  * A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -87,14 +75,7 @@ export class EQ extends DBC {
87
75
  propertyKey: string,
88
76
  descriptor: PropertyDescriptor,
89
77
  ) => PropertyDescriptor {
90
- return DBC.decPostcondition(
91
- (value: object, target: object, propertyKey: string) => {
92
- return EQ.checkAlgorithm(value, equivalent, invert);
93
- },
94
- dbc,
95
- path,
96
- hint
97
- );
78
+ return DBC.createPOST(EQ.checkAlgorithm, [equivalent, invert], dbc, path, hint);
98
79
  }
99
80
  /**
100
81
  * A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -113,7 +94,7 @@ export class EQ extends DBC {
113
94
  hint: string | undefined = undefined,
114
95
  dbc: string | undefined = undefined,
115
96
  ) {
116
- return DBC.decInvariant([new EQ(equivalent, invert)], path, dbc, hint);
97
+ return DBC.createINVARIANT(EQ, [equivalent, invert], dbc, path, hint);
117
98
  }
118
99
  // #endregion Condition checking.
119
100
  // #region Referenced Condition checking.
@@ -138,7 +119,7 @@ export class EQ extends DBC {
138
119
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link EQ }.
139
120
  *
140
121
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link EQ }.*/
141
- public static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
122
+ public static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
142
123
  const result = EQ.checkAlgorithm(toCheck, equivalent, false);
143
124
 
144
125
  if (result) {
@@ -19,16 +19,16 @@ export class HasAttribute extends DBC {
19
19
  toCheckFor: string,
20
20
  invert,
21
21
  ): boolean | string {
22
- if(!( toCheck instanceof HTMLElement )) {
23
- return `The object to check for whether it has the attribute "${ toCheckFor }" is not a HTMLElement. It is of type "${ typeof toCheck }".`;
22
+ if (!(toCheck instanceof HTMLElement)) {
23
+ return `The object to check for whether it has the attribute "${toCheckFor}" is not a HTMLElement. It is of type "${typeof toCheck}".`;
24
24
  }
25
25
 
26
- if (!invert && !( toCheck as HTMLElement ).hasAttribute( toCheckFor )) {
27
- return `Required Attribute "${ toCheckFor }" is not set.`;
26
+ if (!invert && !(toCheck as HTMLElement).hasAttribute(toCheckFor)) {
27
+ return `Required Attribute "${toCheckFor}" is not set.`;
28
28
  }
29
29
 
30
- if (invert && ( toCheck as HTMLElement ).hasAttribute( toCheckFor )) {
31
- return `Forbidden Attribute "${ toCheckFor }" is set.`;
30
+ if (invert && (toCheck as HTMLElement).hasAttribute(toCheckFor)) {
31
+ return `Forbidden Attribute "${toCheckFor}" is set.`;
32
32
  }
33
33
 
34
34
  return true;
@@ -52,18 +52,7 @@ export class HasAttribute extends DBC {
52
52
  methodName: string | symbol,
53
53
  parameterIndex: number,
54
54
  ) => void {
55
- return DBC.decPrecondition(
56
- (
57
- value: object,
58
- target: object,
59
- methodName: string,
60
- parameterIndex: number,
61
- ) => {
62
- return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
63
- },
64
- dbc,
65
- path,
66
- );
55
+ return DBC.createPRE(HasAttribute.checkAlgorithm, [toCheckFor, invert], dbc, path);
67
56
  }
68
57
  /**
69
58
  * A method-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
@@ -84,13 +73,7 @@ export class HasAttribute extends DBC {
84
73
  propertyKey: string,
85
74
  descriptor: PropertyDescriptor,
86
75
  ) => PropertyDescriptor {
87
- return DBC.decPostcondition(
88
- (value: object, target: object, propertyKey: string) => {
89
- return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
90
- },
91
- dbc,
92
- path,
93
- );
76
+ return DBC.createPOST(HasAttribute.checkAlgorithm, [toCheckFor, invert], dbc, path);
94
77
  }
95
78
  /**
96
79
  * A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
@@ -107,7 +90,7 @@ export class HasAttribute extends DBC {
107
90
  path: string | undefined = undefined,
108
91
  dbc = "WaXCode.DBC",
109
92
  ) {
110
- return DBC.decInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
93
+ return DBC.createINVARIANT(HasAttribute, [toCheckFor, invert], dbc, path);
111
94
  }
112
95
  /**
113
96
  * A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
package/src/DBC/IF.ts CHANGED
@@ -22,14 +22,14 @@ export class IF extends DBC {
22
22
  inCase: {
23
23
  check: (toCheck: unknown | undefined | null | object) => boolean | string;
24
24
  },
25
- invert,
25
+ invert: boolean = false,
26
26
  ): boolean | string {
27
- if (invert && !condition.check(toCheck) && !inCase.check(toCheck)) {
28
- return `In case that the value complies to "${condition}" it also has to comply to "${inCase}"`;
27
+ if (invert && condition.check(toCheck) !== true && inCase.check(toCheck) !== true) {
28
+ return `In case that the value does not comply to the condition, it also has to comply to the required contract`;
29
29
  }
30
30
 
31
- if (!invert && condition.check(toCheck) && !inCase.check(toCheck)) {
32
- return `In case that the value does not comply to "${condition}" it has to comply to "${inCase}"`;
31
+ if (!invert && condition.check(toCheck) === true && inCase.check(toCheck) !== true) {
32
+ return `In case that the value complies to the condition, it has to comply to the required contract`;
33
33
  }
34
34
 
35
35
  return true;
@@ -56,19 +56,7 @@ export class IF extends DBC {
56
56
  methodName: string | symbol,
57
57
  parameterIndex: number,
58
58
  ) => void {
59
- return DBC.decPrecondition(
60
- (
61
- value: object,
62
- target: object,
63
- methodName: string,
64
- parameterIndex: number,
65
- ) => {
66
- return IF.checkAlgorithm(value, condition, inCase, invert);
67
- },
68
- dbc,
69
- path,
70
- hint
71
- );
59
+ return DBC.createPRE(IF.checkAlgorithm, [condition, inCase, invert], dbc, path, hint);
72
60
  }
73
61
  /**
74
62
  * A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -92,14 +80,7 @@ export class IF extends DBC {
92
80
  propertyKey: string,
93
81
  descriptor: PropertyDescriptor,
94
82
  ) => PropertyDescriptor {
95
- return DBC.decPostcondition(
96
- (value: object, target: object, propertyKey: string) => {
97
- return IF.checkAlgorithm(value, condition, inCase, invert);
98
- },
99
- dbc,
100
- path,
101
- hint
102
- );
83
+ return DBC.createPOST(IF.checkAlgorithm, [condition, inCase, invert], dbc, path, hint);
103
84
  }
104
85
  /**
105
86
  * A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -119,7 +100,7 @@ export class IF extends DBC {
119
100
  hint: string | undefined = undefined,
120
101
  dbc: string | undefined = undefined,
121
102
  ) {
122
- return DBC.decInvariant([new IF(condition, inCase, invert)], path, dbc, hint);
103
+ return DBC.createINVARIANT(IF, [condition, inCase, invert], dbc, path, hint);
123
104
  }
124
105
  // #endregion Condition checking.
125
106
  // #region Referenced Condition checking.
@@ -47,19 +47,8 @@ export class INSTANCE extends DBC {
47
47
  methodName: string | symbol,
48
48
  parameterIndex: number,
49
49
  ) => void {
50
- return DBC.decPrecondition(
51
- (
52
- value: object,
53
- target: object,
54
- methodName: string,
55
- parameterIndex: number,
56
- ) => {
57
- return Array.isArray(reference) ? INSTANCE.checkAlgorithm(value, ...reference) : INSTANCE.checkAlgorithm(value, reference);
58
- },
59
- dbc,
60
- path,
61
- hint
62
- );
50
+ const refs = Array.isArray(reference) ? reference : [reference];
51
+ return DBC.createPRE(INSTANCE.checkAlgorithm, refs, dbc, path, hint);
63
52
  }
64
53
  /**
65
54
  * A method-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -81,14 +70,8 @@ export class INSTANCE extends DBC {
81
70
  propertyKey: string,
82
71
  descriptor: PropertyDescriptor,
83
72
  ) => PropertyDescriptor {
84
- return DBC.decPostcondition(
85
- (value: object, target: object, propertyKey: string) => {
86
- return Array.isArray(reference) ? INSTANCE.checkAlgorithm(value, ...reference) : INSTANCE.checkAlgorithm(value, reference);
87
- },
88
- dbc,
89
- path,
90
- hint
91
- );
73
+ const refs = Array.isArray(reference) ? reference : [reference];
74
+ return DBC.createPOST(INSTANCE.checkAlgorithm, refs, dbc, path, hint);
92
75
  }
93
76
  /**
94
77
  * A field-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -106,7 +89,7 @@ export class INSTANCE extends DBC {
106
89
  hint: string | undefined = undefined,
107
90
  dbc: string | undefined = undefined,
108
91
  ) {
109
- return DBC.decInvariant([new INSTANCE(reference)], path, dbc, hint);
92
+ return DBC.createINVARIANT(INSTANCE, [reference], dbc, path, hint);
110
93
  }
111
94
  // #endregion Condition checking.
112
95
  // #region Referenced Condition checking.
@@ -23,7 +23,7 @@ export class JSON_OP extends DBC {
23
23
  necessaryProperties: Array<{ name: string; type: string }>,
24
24
  checkElements,
25
25
  ): boolean | string {
26
- if (toCheck === undefined || null) {
26
+ if (toCheck === undefined || toCheck === null) {
27
27
  return `[ UNDEFINED or NULL received instead of object with following properties: ${JSON.stringify(necessaryProperties)} ]`;
28
28
  }
29
29
 
@@ -71,22 +71,7 @@ export class JSON_OP extends DBC {
71
71
  methodName: string | symbol,
72
72
  parameterIndex: number,
73
73
  ) => void {
74
- return DBC.decPrecondition(
75
- (
76
- value: string,
77
- target: object,
78
- methodName: string,
79
- parameterIndex: number,
80
- ) => {
81
- return JSON_OP.checkAlgorithm(
82
- value,
83
- necessaryProperties,
84
- checkElements,
85
- );
86
- },
87
- dbc,
88
- path,
89
- );
74
+ return DBC.createPRE(JSON_OP.checkAlgorithm, [necessaryProperties, checkElements], dbc, path);
90
75
  }
91
76
  /**
92
77
  * A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -107,18 +92,7 @@ export class JSON_OP extends DBC {
107
92
  propertyKey: string,
108
93
  descriptor: PropertyDescriptor,
109
94
  ) => PropertyDescriptor {
110
- return DBC.decPostcondition(
111
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
112
- (value: any, target: object, propertyKey: string) => {
113
- return JSON_OP.checkAlgorithm(
114
- value,
115
- necessaryProperties,
116
- checkElements,
117
- );
118
- },
119
- dbc,
120
- path,
121
- );
95
+ return DBC.createPOST(JSON_OP.checkAlgorithm, [necessaryProperties, checkElements], dbc, path);
122
96
  }
123
97
  /**
124
98
  * A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -135,11 +109,7 @@ export class JSON_OP extends DBC {
135
109
  path: string | undefined = undefined,
136
110
  dbc = "WaXCode.DBC",
137
111
  ) {
138
- return DBC.decInvariant(
139
- [new JSON_OP(necessaryProperties, checkElements)],
140
- path,
141
- dbc,
142
- );
112
+ return DBC.createINVARIANT(JSON_OP, [necessaryProperties, checkElements], dbc, path);
143
113
  }
144
114
  // #endregion Condition checking.
145
115
  // #region Referenced Condition checking.
@@ -52,19 +52,7 @@ export class JSON_Parse extends DBC {
52
52
  methodName: string | symbol,
53
53
  parameterIndex: number,
54
54
  ) => void {
55
- return DBC.decPrecondition(
56
- (
57
- value: string,
58
- target: object,
59
- methodName: string,
60
- parameterIndex: number,
61
- ) => {
62
- return JSON_Parse.checkAlgorithm(value, receptor);
63
- },
64
- dbc,
65
- path,
66
- hint
67
- );
55
+ return DBC.createPRE(JSON_Parse.checkAlgorithm, [receptor], dbc, path, hint);
68
56
  }
69
57
  /**
70
58
  * A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -85,15 +73,7 @@ export class JSON_Parse extends DBC {
85
73
  propertyKey: string,
86
74
  descriptor: PropertyDescriptor,
87
75
  ) => PropertyDescriptor {
88
- return DBC.decPostcondition(
89
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
90
- (value: any, target: object, propertyKey: string) => {
91
- return JSON_Parse.checkAlgorithm(value, receptor);
92
- },
93
- dbc,
94
- path,
95
- hint
96
- );
76
+ return DBC.createPOST(JSON_Parse.checkAlgorithm, [receptor], dbc, path, hint);
97
77
  }
98
78
  /**
99
79
  * A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -110,7 +90,7 @@ export class JSON_Parse extends DBC {
110
90
  hint: string | undefined = undefined,
111
91
  dbc: string | undefined = undefined,
112
92
  ) {
113
- return DBC.decInvariant([new JSON_Parse(receptor)], path, dbc, hint);
93
+ return DBC.createINVARIANT(JSON_Parse, [receptor], dbc, path, hint);
114
94
  }
115
95
  // #endregion Condition checking.
116
96
  // #region Referenced Condition checking.
@@ -125,14 +105,14 @@ export class JSON_Parse extends DBC {
125
105
  * @returns See {@link JSON_Parse.checkAlgorithm}. */
126
106
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
127
107
  public check(toCheck: any) {
128
- return JSON_Parse.checkAlgorithm(toCheck, this.receptor);
108
+ return JSON_Parse.checkAlgorithm(toCheck, this.receptor as (json: object) => void);
129
109
  }
130
110
  /**
131
111
  * Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
132
112
  *
133
113
  * @param necessaryProperties See {@link JSON_Parse.check }.
134
114
  * @param checkElements See {@link JSON_Parse.check }. */
135
- public constructor(public receptor: (json: object) => void = undefined) {
115
+ public constructor(public receptor: ((json: object) => void) | undefined = undefined) {
136
116
  super();
137
117
  }
138
118
  // #endregion Referenced Condition checking.
package/src/DBC/OR.ts CHANGED
@@ -74,17 +74,10 @@ export class OR extends DBC {
74
74
  parameterIndex: number,
75
75
  ) => void {
76
76
  return DBC.decPrecondition(
77
- (
78
- value: object,
79
- target: object,
80
- methodName: string,
81
- parameterIndex: number,
82
- ) => {
83
- return OR.checkAlgorithm(conditions, value);
84
- },
77
+ (value) => OR.checkAlgorithm(conditions, value),
85
78
  dbc,
86
79
  path,
87
- hint
80
+ hint,
88
81
  );
89
82
  }
90
83
  /**
@@ -111,12 +104,10 @@ export class OR extends DBC {
111
104
  descriptor: PropertyDescriptor,
112
105
  ) => PropertyDescriptor {
113
106
  return DBC.decPostcondition(
114
- (value: object, target: object, propertyKey: string) => {
115
- return OR.checkAlgorithm(conditions, value);
116
- },
107
+ (value) => OR.checkAlgorithm(conditions, value),
117
108
  dbc,
118
109
  path,
119
- hint
110
+ hint,
120
111
  );
121
112
  }
122
113
  /**
@@ -137,7 +128,7 @@ export class OR extends DBC {
137
128
  hint: string | undefined = undefined,
138
129
  dbc: string | undefined = undefined,
139
130
  ) {
140
- return DBC.decInvariant([new OR(conditions)], path, dbc, hint);
131
+ return DBC.createINVARIANT(OR, [conditions], dbc, path, hint);
141
132
  }
142
133
  // #endregion Condition checking.
143
134
  // #region Referenced Condition checking.