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
@@ -14,7 +14,10 @@ export class INSTANCE extends DBC {
14
14
  *
15
15
  * @returns TRUE if the value **toCheck** is is an instance of the *reference**, **undefined** or **null**, otherwise FALSE. */
16
16
  // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
17
- public static checkAlgorithm(toCheck: any, ...references: any[]): boolean | string {
17
+ public static checkAlgorithm(
18
+ toCheck: any,
19
+ ...references: any[]
20
+ ): boolean | string {
18
21
  if (toCheck === null || toCheck === undefined) {
19
22
  return true;
20
23
  }
@@ -25,7 +28,7 @@ export class INSTANCE extends DBC {
25
28
  }
26
29
  }
27
30
 
28
- return `Value has to be an instance of "${references.map(ref => ref.name || ref).join(', ')}" but is of type "${typeof toCheck}"`;
31
+ return `Value has to be an instance of "${references.map((ref) => ref.name || ref).join(", ")}" but is of type "${typeof toCheck}"`;
29
32
  }
30
33
  /**
31
34
  * A parameter-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -104,42 +107,54 @@ export class INSTANCE extends DBC {
104
107
  * @returns See {@link INSTANCE.checkAlgorithm}. */
105
108
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
106
109
  public check(toCheck: any) {
107
- return Array.isArray(this.reference) ? INSTANCE.checkAlgorithm(toCheck, ...this.reference) : INSTANCE.checkAlgorithm(toCheck, this.reference);
110
+ return Array.isArray(this.reference)
111
+ ? INSTANCE.checkAlgorithm(toCheck, ...this.reference)
112
+ : INSTANCE.checkAlgorithm(toCheck, this.reference);
108
113
  }
109
114
  /**
110
115
  * Type-safe check that validates if a value is an instance of a specified reference.
111
- *
116
+ *
112
117
  * @param toCheck The value to check for instance validity.
113
118
  * @param reference The {@link object } the one **toCheck** has to be an instance of.
114
119
  * @param hint An optional {@link string } providing extra information in case of an infringement.
115
120
  * @param id A {@link string } identifying this {@link INSTANCE } via the {@link DBC.Infringement }-Message.
116
- *
121
+ *
117
122
  * @returns The **CANDIDATE** **toCheck** if it fulfills this {@link INSTANCE }.
118
- *
123
+ *
119
124
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link INSTANCE }. */
120
- public static tsCheck<CANDIDATE = unknown>(toCheck: any, reference: any, hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
125
+ public static tsCheck<CANDIDATE = unknown>(
126
+ toCheck: any,
127
+ reference: any,
128
+ hint: string = undefined,
129
+ id: string | undefined = undefined,
130
+ ): CANDIDATE {
121
131
  return INSTANCE.tsCheckMulti<CANDIDATE>(toCheck, [reference], hint, id);
122
132
  }
123
133
  /**
124
134
  * Invokes the {@link INSTANCE.checkAlgorithm } passing the value **toCheck** and the {@link INSTANCE.reference } .
125
- *
135
+ *
126
136
  * @param toCheck See {@link INSTANCE.checkAlgorithm }.
127
137
  * @param reference See {@link INSTANCE.checkAlgorithm }.
128
138
  * @param hint An optional {@link string } providing extra information in case of an infringement.
129
139
  * @param id A {@link string } identifying this {@link INSTANCE } via the {@link DBC.Infringement }-Message.
130
- *
140
+ *
131
141
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link INSTANCE }.
132
- *
142
+ *
133
143
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
134
- public static tsCheckMulti<CANDIDATE = unknown>(toCheck: any, references: any[], hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
144
+ public static tsCheckMulti<CANDIDATE = unknown>(
145
+ toCheck: any,
146
+ references: any[],
147
+ hint: string = undefined,
148
+ id: string | undefined = undefined,
149
+ ): CANDIDATE {
135
150
  const result = INSTANCE.checkAlgorithm(toCheck, ...references);
136
151
 
137
152
  if (result === true) {
138
153
  return toCheck;
139
154
  }
140
- else {
141
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string} ${hint ? `✨ ${hint} ✨` : ""}`);
142
- }
155
+ throw new DBC.Infringement(
156
+ `${id ? `(${id}) ` : ""}${result as string} ${hint ? `✨ ${hint} ✨` : ""}`,
157
+ );
143
158
  }
144
159
  /**
145
160
  * Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
@@ -71,7 +71,12 @@ export class JSON_OP extends DBC {
71
71
  methodName: string | symbol,
72
72
  parameterIndex: number,
73
73
  ) => void {
74
- return DBC.createPRE(JSON_OP.checkAlgorithm, [necessaryProperties, checkElements], dbc, path);
74
+ return DBC.createPRE(
75
+ JSON_OP.checkAlgorithm,
76
+ [necessaryProperties, checkElements],
77
+ dbc,
78
+ path,
79
+ );
75
80
  }
76
81
  /**
77
82
  * A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -92,7 +97,12 @@ export class JSON_OP extends DBC {
92
97
  propertyKey: string,
93
98
  descriptor: PropertyDescriptor,
94
99
  ) => PropertyDescriptor {
95
- return DBC.createPOST(JSON_OP.checkAlgorithm, [necessaryProperties, checkElements], dbc, path);
100
+ return DBC.createPOST(
101
+ JSON_OP.checkAlgorithm,
102
+ [necessaryProperties, checkElements],
103
+ dbc,
104
+ path,
105
+ );
96
106
  }
97
107
  /**
98
108
  * A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -109,7 +119,12 @@ export class JSON_OP extends DBC {
109
119
  path: string | undefined = undefined,
110
120
  dbc = "WaXCode.DBC",
111
121
  ) {
112
- return DBC.createINVARIANT(JSON_OP, [necessaryProperties, checkElements], dbc, path);
122
+ return DBC.createINVARIANT(
123
+ JSON_OP,
124
+ [necessaryProperties, checkElements],
125
+ dbc,
126
+ path,
127
+ );
113
128
  }
114
129
  // #endregion Condition checking.
115
130
  // #region Referenced Condition checking.
@@ -52,7 +52,13 @@ export class JSON_Parse extends DBC {
52
52
  methodName: string | symbol,
53
53
  parameterIndex: number,
54
54
  ) => void {
55
- return DBC.createPRE(JSON_Parse.checkAlgorithm, [receptor], dbc, path, hint);
55
+ return DBC.createPRE(
56
+ JSON_Parse.checkAlgorithm,
57
+ [receptor],
58
+ dbc,
59
+ path,
60
+ hint,
61
+ );
56
62
  }
57
63
  /**
58
64
  * A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -73,7 +79,13 @@ export class JSON_Parse extends DBC {
73
79
  propertyKey: string,
74
80
  descriptor: PropertyDescriptor,
75
81
  ) => PropertyDescriptor {
76
- return DBC.createPOST(JSON_Parse.checkAlgorithm, [receptor], dbc, path, hint);
82
+ return DBC.createPOST(
83
+ JSON_Parse.checkAlgorithm,
84
+ [receptor],
85
+ dbc,
86
+ path,
87
+ hint,
88
+ );
77
89
  }
78
90
  /**
79
91
  * A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
@@ -105,14 +117,19 @@ export class JSON_Parse extends DBC {
105
117
  * @returns See {@link JSON_Parse.checkAlgorithm}. */
106
118
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
107
119
  public check(toCheck: any) {
108
- return JSON_Parse.checkAlgorithm(toCheck, this.receptor as (json: object) => void);
120
+ return JSON_Parse.checkAlgorithm(
121
+ toCheck,
122
+ this.receptor as (json: object) => void,
123
+ );
109
124
  }
110
125
  /**
111
126
  * Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
112
127
  *
113
128
  * @param necessaryProperties See {@link JSON_Parse.check }.
114
129
  * @param checkElements See {@link JSON_Parse.check }. */
115
- public constructor(public receptor: ((json: object) => void) | undefined = undefined) {
130
+ public constructor(
131
+ public receptor: ((json: object) => void) | undefined = undefined,
132
+ ) {
116
133
  super();
117
134
  }
118
135
  // #endregion Referenced Condition checking.
package/src/DBC/OR.ts CHANGED
@@ -150,19 +150,24 @@ export class OR extends DBC {
150
150
  * @param toCheck See {@link OR.checkAlgorithm }.
151
151
  *
152
152
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link OR }.
153
- *
153
+ *
154
154
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link OR }.*/
155
- public static tsCheck<CANDIDATE>(toCheck: unknown | undefined | null, conditions: Array<{
156
- check: (toCheck: unknown | undefined | null | object) => boolean | string;
157
- }>, hint: string = undefined, id: string | undefined = undefined): CANDIDATE {
155
+ public static tsCheck<CANDIDATE>(
156
+ toCheck: unknown | undefined | null,
157
+ conditions: Array<{
158
+ check: (toCheck: unknown | undefined | null | object) => boolean | string;
159
+ }>,
160
+ hint: string = undefined,
161
+ id: string | undefined = undefined,
162
+ ): CANDIDATE {
158
163
  const result = OR.checkAlgorithm(conditions, toCheck);
159
164
 
160
165
  if (result) {
161
166
  return toCheck as CANDIDATE;
162
167
  }
163
- else {
164
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`);
165
- }
168
+ throw new DBC.Infringement(
169
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
170
+ );
166
171
  }
167
172
  /**
168
173
  * Creates this {@link OR } by setting the protected property {@link OR.conditions } used by {@link OR.check }.
package/src/DBC/REGEX.ts CHANGED
@@ -6,20 +6,22 @@ import { DBC } from "../DBC";
6
6
  * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
7
  export class REGEX extends DBC {
8
8
  /** Stores often used {@link RegExp }s. Patterns are compiled lazily on first access. */
9
- private static _stdExp: {
10
- htmlAttributeName: RegExp;
11
- eMail: RegExp;
12
- property: RegExp;
13
- url: RegExp;
14
- keyPath: RegExp;
15
- date: RegExp;
16
- dateFormat: RegExp;
17
- cssSelector: RegExp;
18
- boolean: RegExp;
19
- colorCodeHEX: RegExp;
20
- simpleHotkey: RegExp;
21
- bcp47: RegExp;
22
- } | undefined;
9
+ private static _stdExp:
10
+ | {
11
+ htmlAttributeName: RegExp;
12
+ eMail: RegExp;
13
+ property: RegExp;
14
+ url: RegExp;
15
+ keyPath: RegExp;
16
+ date: RegExp;
17
+ dateFormat: RegExp;
18
+ cssSelector: RegExp;
19
+ boolean: RegExp;
20
+ colorCodeHEX: RegExp;
21
+ simpleHotkey: RegExp;
22
+ bcp47: RegExp;
23
+ }
24
+ | undefined;
23
25
 
24
26
  public static get stdExp() {
25
27
  if (!REGEX._stdExp) {
@@ -37,7 +39,8 @@ export class REGEX extends DBC {
37
39
  boolean: /^(TRUE|FALSE)$/i,
38
40
  colorCodeHEX: /^#([A-Fa-f\d]{3,4}|[A-Fa-f\d]{6}|[A-Fa-f\d]{8})$/i,
39
41
  simpleHotkey: /^((Alt|Ctrl|Shift|Meta)\+)+[a-z\d]$/i,
40
- bcp47: /^(?:[a-z]{2,3}(?:-[a-z]{3}){0,3}|[a-z]{4}|[a-z]{5,8})(?:-[a-z]{4})?(?:-[a-z]{2}|-[0-9]{3})?(?:-[a-z0-9]{5,8}|-[0-9][a-z0-9]{3})*(?:-[0-9a-wy-z](?:-[a-z0-9]{2,8})+)*(?:-x(?:-[a-z0-9]{1,8})+)?$|^x(?:-[a-z0-9]{1,8})+$/i
42
+ bcp47:
43
+ /^(?:[a-z]{2,3}(?:-[a-z]{3}){0,3}|[a-z]{4}|[a-z]{5,8})(?:-[a-z]{4})?(?:-[a-z]{2}|-[0-9]{3})?(?:-[a-z0-9]{5,8}|-[0-9][a-z0-9]{3})*(?:-[0-9a-wy-z](?:-[a-z0-9]{2,8})+)*(?:-x(?:-[a-z0-9]{1,8})+)?$|^x(?:-[a-z0-9]{1,8})+$/i,
41
44
  };
42
45
  }
43
46
  return REGEX._stdExp;
@@ -55,7 +58,8 @@ export class REGEX extends DBC {
55
58
  toCheck: unknown | null | undefined,
56
59
  expression: RegExp,
57
60
  ): boolean | string {
58
- if (toCheck === undefined || toCheck === null || toCheck === "") return true;
61
+ if (toCheck === undefined || toCheck === null || toCheck === "")
62
+ return true;
59
63
 
60
64
  if (!expression.test(toCheck as string)) {
61
65
  return `Value has to comply to regular expression "${expression}"`;
@@ -146,17 +150,22 @@ export class REGEX extends DBC {
146
150
  * @param id Optional identifier to include in the error message.
147
151
  *
148
152
  * @returns The validated value cast to the CANDIDATE type.
149
- *
153
+ *
150
154
  * @throws {@link DBC.Infringement} if the value does not match the regular expression. */
151
- public static tsCheck<CANDIDATE = unknown>(toCheck: any, expression: RegExp, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
155
+ public static tsCheck<CANDIDATE = unknown>(
156
+ toCheck: any,
157
+ expression: RegExp,
158
+ hint: string | undefined = undefined,
159
+ id: string | undefined = undefined,
160
+ ): CANDIDATE {
152
161
  const result = REGEX.checkAlgorithm(toCheck, expression);
153
162
 
154
163
  if (result) {
155
164
  return toCheck;
156
165
  }
157
- else {
158
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`);
159
- }
166
+ throw new DBC.Infringement(
167
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
168
+ );
160
169
  }
161
170
  /**
162
171
  * Creates this {@link REGEX } by setting the protected property {@link REGEX.expression } used by {@link REGEX.check }.
package/src/DBC/TYPE.ts CHANGED
@@ -17,12 +17,12 @@ export class TYPE extends DBC {
17
17
  public static checkAlgorithm(toCheck: any, type: string): boolean | string {
18
18
  if (toCheck === undefined || toCheck === null) return true;
19
19
 
20
- const types = type.split("|").map(t => t.trim());
20
+ const types = type.split("|").map((t) => t.trim());
21
21
  const actualType = typeof toCheck;
22
22
 
23
23
  // #region Check if the actual type matches at least one of the specified types
24
24
  // biome-ignore lint/suspicious/useValidTypeof: Necessary
25
- const isValid = types.some(t => actualType === t);
25
+ const isValid = types.some((t) => actualType === t);
26
26
 
27
27
  if (!isValid) {
28
28
  if (types.length === 1) {
@@ -47,7 +47,7 @@ export class TYPE extends DBC {
47
47
  type: string,
48
48
  path: string | undefined = undefined,
49
49
  hint: string | undefined = undefined,
50
- dbc: string | undefined = undefined
50
+ dbc: string | undefined = undefined,
51
51
  ): (
52
52
  target: object,
53
53
  methodName: string | symbol,
@@ -70,7 +70,6 @@ export class TYPE extends DBC {
70
70
  path: string | undefined = undefined,
71
71
  hint: string | undefined = undefined,
72
72
  dbc: string | undefined = undefined,
73
-
74
73
  ): (
75
74
  target: object,
76
75
  propertyKey: string,
@@ -113,24 +112,29 @@ export class TYPE extends DBC {
113
112
  }
114
113
  /**
115
114
  * Invokes the {@link TYPE.checkAlgorithm } passing the value **toCheck** and the {@link TYPE.type } .
116
- *
115
+ *
117
116
  * @param toCheck See {@link TYPE.checkAlgorithm }.
118
117
  * @param type See {@link TYPE.checkAlgorithm }.
119
118
  * @param hint An optional {@link string } providing extra information in case of an infringement.
120
119
  * @param id A {@link string } identifying this {@link TYPE } via the {@link DBC.Infringement }-Message.
121
- *
120
+ *
122
121
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link TYPE }.
123
- *
122
+ *
124
123
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
125
- public static tsCheck<CANDIDATE = unknown>(toCheck: any, type: string, hint: string | undefined = undefined, id: string | undefined = undefined): CANDIDATE {
124
+ public static tsCheck<CANDIDATE = unknown>(
125
+ toCheck: any,
126
+ type: string,
127
+ hint: string | undefined = undefined,
128
+ id: string | undefined = undefined,
129
+ ): CANDIDATE {
126
130
  const result = TYPE.checkAlgorithm(toCheck, type);
127
131
 
128
132
  if (result === true) {
129
133
  return toCheck;
130
134
  }
131
- else {
132
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`);
133
- }
135
+ throw new DBC.Infringement(
136
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
137
+ );
134
138
  }
135
139
  /**
136
140
  * Creates this {@link TYPE } by setting the protected property {@link TYPE.type } used by {@link TYPE.check }.
@@ -97,22 +97,19 @@ export class UNDEFINED extends DBC {
97
97
  *
98
98
  * @param toCheck See {@link UNDEFINED.checkAlgorithm }.
99
99
  * @param id A {@link string } identifying this {@link INSTANCE } via the {@link DBC.Infringement }-Message.
100
- *
100
+ *
101
101
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link UNDEFINED }.
102
- *
102
+ *
103
103
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link UNDEFINED }.*/
104
- public static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, id: string | undefined = undefined): CANDIDATE {
104
+ public static tsCheck<CANDIDATE = unknown>(
105
+ toCheck: CANDIDATE | undefined | null,
106
+ id: string | undefined = undefined,
107
+ ): CANDIDATE {
105
108
  const result = UNDEFINED.checkAlgorithm(toCheck);
106
109
 
107
110
  if (result === true) {
108
111
  return toCheck as CANDIDATE;
109
112
  }
110
- else {
111
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}`);
112
- }
113
- }
114
- /** Creates this {@link UNDEFINED }. */
115
- public constructor() {
116
- super();
113
+ throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}`);
117
114
  }
118
115
  }
package/src/DBC/ZOD.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { z } from "zod";
1
2
  import { DBC } from "../DBC";
2
- import { z } from 'zod';
3
3
  /**
4
4
  * A {@link DBC } defining that the an {@link object }s gotta be an instance of a certain {@link ZOD.schema }.
5
5
  *
@@ -15,7 +15,10 @@ export class ZOD extends DBC {
15
15
  *
16
16
  * @returns TRUE if the value **toCheck** complies to the specified **schema**, otherwise FALSE. */
17
17
  // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
18
- public static checkAlgorithm(toCheck: any, schema: z.ZodType): boolean | string {
18
+ public static checkAlgorithm(
19
+ toCheck: any,
20
+ schema: z.ZodType,
21
+ ): boolean | string {
19
22
  const result = schema.safeParse(toCheck);
20
23
  if (!result.success) {
21
24
  return `Value does not comply to the specified schema. Received: "${JSON.stringify(toCheck)}". Errors: ${result.error.message}`;
@@ -99,23 +102,25 @@ export class ZOD extends DBC {
99
102
  }
100
103
  /**
101
104
  * Invokes the {@link ZOD.checkAlgorithm } passing the value **toCheck** and the {@link ZOD.schema } .
102
- *
105
+ *
103
106
  * @param toCheck See {@link ZOD.checkAlgorithm }.
104
107
  * @param schema See {@link ZOD.checkAlgorithm }.
105
108
  * @param id A {@link string } identifying this {@link ZOD } via the {@link DBC.Infringement }-Message.
106
- *
109
+ *
107
110
  * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link ZOD }.
108
- *
111
+ *
109
112
  * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
110
- public static tsCheck<CANDIDATE = unknown>(toCheck: any, schema: z.ZodType, id: string | undefined = undefined): CANDIDATE {
113
+ public static tsCheck<CANDIDATE = unknown>(
114
+ toCheck: any,
115
+ schema: z.ZodType,
116
+ id: string | undefined = undefined,
117
+ ): CANDIDATE {
111
118
  const result = ZOD.checkAlgorithm(toCheck, schema);
112
119
 
113
120
  if (result === true) {
114
121
  return toCheck;
115
122
  }
116
- else {
117
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}`);
118
- }
123
+ throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result as string}`);
119
124
  }
120
125
  /**
121
126
  * Creates this {@link ZOD } by setting the protected property {@link ZOD.schema } used by {@link ZOD.check }.