xdbc 1.0.217 → 1.0.218

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 (89) hide show
  1. package/.gitattributes +8 -0
  2. package/.vscode/settings.json +3 -3
  3. package/.vscode/tasks.json +23 -23
  4. package/ASSESSMENT.md +249 -0
  5. package/README.md +131 -1
  6. package/__tests__/DBC/AE.test.ts +62 -62
  7. package/__tests__/DBC/ARRAY.test.ts +91 -91
  8. package/__tests__/DBC/DEFINED.test.ts +53 -53
  9. package/__tests__/DBC/DOM.test.ts +481 -0
  10. package/__tests__/DBC/Decorators.test.ts +367 -367
  11. package/__tests__/DBC/EQ.test.ts +13 -13
  12. package/__tests__/DBC/GREATER.test.ts +31 -31
  13. package/__tests__/DBC/HasAttribute.test.ts +60 -60
  14. package/__tests__/DBC/IF.test.ts +62 -62
  15. package/__tests__/DBC/INSTANCE.test.ts +13 -13
  16. package/__tests__/DBC/JSON.OP.test.ts +47 -47
  17. package/__tests__/DBC/JSON.Parse.test.ts +17 -17
  18. package/__tests__/DBC/OR.test.ts +14 -14
  19. package/__tests__/DBC/PLAIN_OBJECT.test.ts +109 -109
  20. package/__tests__/DBC/REGEX.test.ts +17 -17
  21. package/__tests__/DBC/TYPE.test.ts +13 -13
  22. package/__tests__/DBC/UNDEFINED.test.ts +45 -45
  23. package/__tests__/DBC/ZOD.test.ts +54 -54
  24. package/__tests__/DBC/onInfringement.test.ts +262 -0
  25. package/biome.json +40 -40
  26. package/dist/DBC/AE.js +172 -0
  27. package/dist/DBC/ARR/PLAIN_OBJECT.d.ts +0 -3
  28. package/dist/DBC/ARR/PLAIN_OBJECT.js +95 -0
  29. package/dist/DBC/ARRAY.d.ts +0 -3
  30. package/dist/DBC/ARRAY.js +90 -0
  31. package/dist/DBC/COMPARISON/GREATER.js +21 -0
  32. package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +21 -0
  33. package/dist/DBC/COMPARISON/LESS.js +21 -0
  34. package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +21 -0
  35. package/dist/DBC/COMPARISON.js +98 -0
  36. package/dist/DBC/DEFINED.js +87 -0
  37. package/dist/DBC/DOM.d.ts +87 -0
  38. package/dist/DBC/DOM.js +223 -0
  39. package/dist/DBC/EQ/DIFFERENT.js +34 -0
  40. package/dist/DBC/EQ.js +101 -0
  41. package/dist/DBC/HasAttribute.js +101 -0
  42. package/dist/DBC/IF.js +96 -0
  43. package/dist/DBC/INSTANCE.js +122 -0
  44. package/dist/DBC/JSON.OP.js +120 -0
  45. package/dist/DBC/JSON.Parse.js +104 -0
  46. package/dist/DBC/OR.js +125 -0
  47. package/dist/DBC/REGEX.js +136 -0
  48. package/dist/DBC/TYPE.js +112 -0
  49. package/dist/DBC/UNDEFINED.js +87 -0
  50. package/dist/DBC/ZOD.js +99 -0
  51. package/dist/DBC.d.ts +18 -4
  52. package/dist/DBC.js +645 -0
  53. package/dist/Demo.d.ts +10 -0
  54. package/dist/Demo.js +713 -0
  55. package/dist/bundle.js +6140 -405
  56. package/dist/index.d.ts +22 -0
  57. package/dist/index.js +22 -0
  58. package/jest.config.js +32 -32
  59. package/package.json +71 -55
  60. package/src/DBC/AE.ts +269 -288
  61. package/src/DBC/ARR/PLAIN_OBJECT.ts +122 -133
  62. package/src/DBC/ARRAY.ts +117 -127
  63. package/src/DBC/COMPARISON/GREATER.ts +41 -46
  64. package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +41 -45
  65. package/src/DBC/COMPARISON/LESS.ts +41 -45
  66. package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +41 -45
  67. package/src/DBC/COMPARISON.ts +149 -159
  68. package/src/DBC/DEFINED.ts +117 -122
  69. package/src/DBC/DOM.ts +291 -0
  70. package/src/DBC/EQ/DIFFERENT.ts +51 -57
  71. package/src/DBC/EQ.ts +154 -163
  72. package/src/DBC/HasAttribute.ts +149 -154
  73. package/src/DBC/IF.ts +173 -179
  74. package/src/DBC/INSTANCE.ts +168 -171
  75. package/src/DBC/JSON.OP.ts +178 -186
  76. package/src/DBC/JSON.Parse.ts +150 -157
  77. package/src/DBC/OR.ts +183 -187
  78. package/src/DBC/REGEX.ts +195 -196
  79. package/src/DBC/TYPE.ts +142 -149
  80. package/src/DBC/UNDEFINED.ts +115 -117
  81. package/src/DBC/ZOD.ts +130 -135
  82. package/src/DBC.ts +902 -904
  83. package/src/Demo.ts +537 -404
  84. package/src/index.ts +22 -0
  85. package/tsconfig.json +18 -18
  86. package/tsconfig.test.json +7 -7
  87. package/typedoc.json +16 -16
  88. package/webpack.config.js +27 -27
  89. package/Assessment.md +0 -507
package/src/DBC/REGEX.ts CHANGED
@@ -1,196 +1,195 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } providing {@link REGEX }-contracts and standard {@link RegExp } for common use cases in {@link REGEX.stdExp }.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class REGEX extends DBC {
8
- /** Stores often used {@link RegExp }s. Patterns are compiled lazily on first access. */
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;
25
-
26
- public static get stdExp() {
27
- if (!REGEX._stdExp) {
28
- REGEX._stdExp = {
29
- htmlAttributeName: /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/,
30
- eMail: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i,
31
- property: /^[$_A-Za-z][$_A-Za-z0-9]*$/,
32
- url: /^(?:https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i,
33
- keyPath: /^([a-zA-Z_$][a-zA-Z0-9_$]*\.)*[a-zA-Z_$][a-zA-Z0-9_$]*$/,
34
- date: /^\d{1,4}[.\/-]\d{1,2}[.\/-]\d{1,4}$/i,
35
- dateFormat:
36
- /^((D{1,2}[./-]M{1,2}[./-]Y{1,4})|(M{1,2}[./-]D{1,2}[./-]Y{1,4})|Y{1,4}[./-]D{1,2}[./-]M{1,2}|(Y{1,4}[./-]M{1,2}[./-]D{1,2}))$/i,
37
- cssSelector:
38
- /^(?:\*|#[\w-]+|\.[\w-]+|(?:[\w-]+|\*)(?::(?:[\w-]+(?:\([\w-]+\))?)+)?(?:\[(?:[\w-]+(?:(?:=|~=|\|=|\*=|\$=|\^=)\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*)?)?\])+|\[\s*[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*\])(?:,\s*(?:\*|#[\w-]+|\.[\w-]+|(?:[\w-]+|\*)(?::(?:[\w-]+(?:\([\w-]+\))?)+)?(?:\[(?:[\w-]+(?:(?:=|~=|\|=|\*=|\$=|\^=)\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*)?)?\])+|\[\s*[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*\]))*$/,
39
- boolean: /^(TRUE|FALSE)$/i,
40
- colorCodeHEX: /^#([A-Fa-f\d]{3,4}|[A-Fa-f\d]{6}|[A-Fa-f\d]{8})$/i,
41
- simpleHotkey: /^((Alt|Ctrl|Shift|Meta)\+)+[a-z\d]$/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,
44
- };
45
- }
46
- return REGEX._stdExp;
47
- }
48
- // #region Condition checking.
49
- /**
50
- * Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
51
- *
52
- * @param toCheck The value that has comply to the {@link RegExp } **expression** for this {@link DBC } to be fulfilled.
53
- * @param expression The {@link RegExp } the one **toCheck** has comply to in order for this {@link DBC } to be
54
- * fulfilled.
55
- *
56
- * @returns TRUE if the value **toCheck** complies with the {@link RegExp } **expression**, otherwise FALSE. */
57
- public static checkAlgorithm(
58
- toCheck: unknown | null | undefined,
59
- expression: RegExp,
60
- ): boolean | string {
61
- if (toCheck === undefined || toCheck === null || toCheck === "")
62
- return true;
63
-
64
- if (!expression.test(toCheck as string)) {
65
- return `Value has to comply to regular expression "${expression}"`;
66
- }
67
-
68
- return true;
69
- }
70
- /**
71
- * A parameter-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
72
- * by the tagged parameter.
73
- *
74
- * @param expression See {@link REGEX.checkAlgorithm }.
75
- * @param path See {@link DBC.decPrecondition }.
76
- * @param dbc See {@link DBC.decPrecondition }.
77
- *
78
- * @returns See {@link DBC.decPrecondition }. */
79
- public static PRE(
80
- expression: RegExp,
81
- path: string | undefined = undefined,
82
- hint: string | undefined = undefined,
83
- dbc: string | undefined = undefined,
84
- ): (
85
- target: object,
86
- methodName: string | symbol | undefined,
87
- parameterIndex: number,
88
- ) => void {
89
- return DBC.createPRE(REGEX.checkAlgorithm, [expression], dbc, path, hint);
90
- }
91
- /**
92
- * A method-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
93
- * by the tagged method's returnvalue.
94
- *
95
- * @param expression See {@link REGEX.checkAlgorithm }.
96
- * @param path See {@link DBC.Postcondition }.
97
- * @param dbc See {@link DBC.decPostcondition }.
98
- * @param hint See {@link DBC.decPostcondition }.
99
- *
100
- * @returns See {@link DBC.decPostcondition }. */
101
- public static POST(
102
- expression: RegExp,
103
- path: string | undefined = undefined,
104
- hint: string | undefined = undefined,
105
- dbc: string | undefined = undefined,
106
- ): (
107
- target: object,
108
- propertyKey: string,
109
- descriptor: PropertyDescriptor,
110
- ) => PropertyDescriptor {
111
- return DBC.createPOST(REGEX.checkAlgorithm, [expression], dbc, path, hint);
112
- }
113
- /**
114
- * A field-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
115
- * by the tagged field.
116
- *
117
- * @param expression See {@link REGEX.checkAlgorithm }.
118
- * @param path See {@link DBC.decInvariant }.
119
- * @param dbc See {@link DBC.decInvariant }.
120
- * @param hint See {@link DBC.decInvariant }.
121
- * @returns See {@link DBC.decInvariant }. */
122
- public static INVARIANT(
123
- expression: RegExp,
124
- path: string | undefined = undefined,
125
- hint: string | undefined = undefined,
126
- dbc: string | undefined = undefined,
127
- ) {
128
- return DBC.createINVARIANT(REGEX, [expression], dbc, path, hint);
129
- }
130
- // #endregion Condition checking.
131
- // #region Referenced Condition checking.
132
- //
133
- // For usage in dynamic scenarios (like with AE-DBC).
134
- //
135
- /**
136
- * Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.equivalent }.
137
- *
138
- * @param toCheck See {@link REGEX.checkAlgorithm }.
139
- *
140
- * @returns See {@link EQ.checkAlgorithm}. */
141
- public check(toCheck: unknown | null | undefined) {
142
- return REGEX.checkAlgorithm(toCheck, this.expression);
143
- }
144
- /**
145
- * Type-safe check that validates a value against a regular expression and returns it as the specified type.
146
- *
147
- * @param toCheck The value to check against the regular expression.
148
- * @param expression The regular expression to validate against.
149
- * @param hint Optional hint message to include in the error if validation fails.
150
- * @param id Optional identifier to include in the error message.
151
- *
152
- * @returns The validated value cast to the CANDIDATE type.
153
- *
154
- * @throws {@link DBC.Infringement} if the value does not match the regular expression. */
155
- public static tsCheck<CANDIDATE = unknown>(
156
- toCheck: any,
157
- expression: RegExp,
158
- hint: string | undefined = undefined,
159
- id: string | undefined = undefined,
160
- dbc: string | undefined = undefined,
161
- ): CANDIDATE {
162
- const result = REGEX.checkAlgorithm(toCheck, expression);
163
-
164
- if (result === true) {
165
- return toCheck;
166
- }
167
- DBC.reportTsCheckInfringement(
168
- `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
169
- dbc,
170
- );
171
- return toCheck as CANDIDATE;
172
- }
173
- /**
174
- * Creates this {@link REGEX } by setting the protected property {@link REGEX.expression } used by {@link REGEX.check }.
175
- *
176
- * @param expression See {@link REGEX.check }. */
177
- public constructor(protected expression: RegExp) {
178
- super();
179
- }
180
- // #endregion Referenced Condition checking.
181
- // #region In-Method checking.
182
- /**
183
- * Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.expression }.
184
- *
185
- * @param toCheck See {@link REGEX.checkAlgorithm}.
186
- * @param expression See {@link REGEX.checkAlgorithm}.
187
- */
188
- public static check(toCheck: unknown | null | undefined, expression: RegExp, dbc: string | undefined = undefined) {
189
- const checkResult = REGEX.checkAlgorithm(toCheck, expression);
190
-
191
- if (typeof checkResult === "string") {
192
- DBC.reportTsCheckInfringement(checkResult, dbc);
193
- }
194
- }
195
- // #endregion In-Method checking.
196
- }
1
+ import { DBC } from "../DBC";
2
+ /**
3
+ * A {@link DBC } providing {@link REGEX }-contracts and standard {@link RegExp } for common use cases in {@link REGEX.stdExp }.
4
+ *
5
+ * @remarks
6
+ * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
+ export class REGEX extends DBC {
8
+ /** Stores often used {@link RegExp }s. Patterns are compiled lazily on first access. */
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;
25
+ public static get stdExp() {
26
+ if (!REGEX._stdExp) {
27
+ REGEX._stdExp = {
28
+ htmlAttributeName: /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/,
29
+ eMail: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i,
30
+ property: /^[$_A-Za-z][$_A-Za-z0-9]*$/,
31
+ url: /^(?:https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i,
32
+ keyPath: /^([a-zA-Z_$][a-zA-Z0-9_$]*\.)*[a-zA-Z_$][a-zA-Z0-9_$]*$/,
33
+ date: /^\d{1,4}[.\/-]\d{1,2}[.\/-]\d{1,4}$/i,
34
+ dateFormat:
35
+ /^((D{1,2}[./-]M{1,2}[./-]Y{1,4})|(M{1,2}[./-]D{1,2}[./-]Y{1,4})|Y{1,4}[./-]D{1,2}[./-]M{1,2}|(Y{1,4}[./-]M{1,2}[./-]D{1,2}))$/i,
36
+ cssSelector:
37
+ /^(?:\*|#[\w-]+|\.[\w-]+|(?:[\w-]+|\*)(?::(?:[\w-]+(?:\([\w-]+\))?)+)?(?:\[(?:[\w-]+(?:(?:=|~=|\|=|\*=|\$=|\^=)\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*)?)?\])+|\[\s*[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*\])(?:,\s*(?:\*|#[\w-]+|\.[\w-]+|(?:[\w-]+|\*)(?::(?:[\w-]+(?:\([\w-]+\))?)+)?(?:\[(?:[\w-]+(?:(?:=|~=|\|=|\*=|\$=|\^=)\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*)?)?\])+|\[\s*[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*\]))*$/,
38
+ boolean: /^(TRUE|FALSE)$/i,
39
+ colorCodeHEX: /^#([A-Fa-f\d]{3,4}|[A-Fa-f\d]{6}|[A-Fa-f\d]{8})$/i,
40
+ simpleHotkey: /^((Alt|Ctrl|Shift|Meta)\+)+[a-z\d]$/i,
41
+ bcp47:
42
+ /^(?:[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,
43
+ };
44
+ }
45
+ return REGEX._stdExp;
46
+ }
47
+ // #region Condition checking.
48
+ /**
49
+ * Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
50
+ *
51
+ * @param toCheck The value that has comply to the {@link RegExp } **expression** for this {@link DBC } to be fulfilled.
52
+ * @param expression The {@link RegExp } the one **toCheck** has comply to in order for this {@link DBC } to be
53
+ * fulfilled.
54
+ *
55
+ * @returns TRUE if the value **toCheck** complies with the {@link RegExp } **expression**, otherwise FALSE. */
56
+ public static checkAlgorithm(
57
+ toCheck: unknown | null | undefined,
58
+ expression: RegExp,
59
+ ): boolean | string {
60
+ if (toCheck === undefined || toCheck === null || toCheck === "")
61
+ return true;
62
+ if (!expression.test(toCheck as string)) {
63
+ return `Value has to comply to regular expression "${expression}"`;
64
+ }
65
+ return true;
66
+ }
67
+ /**
68
+ * A parameter-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
69
+ * by the tagged parameter.
70
+ *
71
+ * @param expression See {@link REGEX.checkAlgorithm }.
72
+ * @param path See {@link DBC.decPrecondition }.
73
+ * @param dbc See {@link DBC.decPrecondition }.
74
+ *
75
+ * @returns See {@link DBC.decPrecondition }. */
76
+ public static PRE(
77
+ expression: RegExp,
78
+ path: string | undefined = undefined,
79
+ hint: string | undefined = undefined,
80
+ dbc: string | undefined = undefined,
81
+ ): (
82
+ target: object,
83
+ methodName: string | symbol | undefined,
84
+ parameterIndex: number,
85
+ ) => void {
86
+ return DBC.createPRE(REGEX.checkAlgorithm, [expression], dbc, path, hint);
87
+ }
88
+ /**
89
+ * A method-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
90
+ * by the tagged method's returnvalue.
91
+ *
92
+ * @param expression See {@link REGEX.checkAlgorithm }.
93
+ * @param path See {@link DBC.Postcondition }.
94
+ * @param dbc See {@link DBC.decPostcondition }.
95
+ * @param hint See {@link DBC.decPostcondition }.
96
+ *
97
+ * @returns See {@link DBC.decPostcondition }. */
98
+ public static POST(
99
+ expression: RegExp,
100
+ path: string | undefined = undefined,
101
+ hint: string | undefined = undefined,
102
+ dbc: string | undefined = undefined,
103
+ ): (
104
+ target: object,
105
+ propertyKey: string,
106
+ descriptor: PropertyDescriptor,
107
+ ) => PropertyDescriptor {
108
+ return DBC.createPOST(REGEX.checkAlgorithm, [expression], dbc, path, hint);
109
+ }
110
+ /**
111
+ * A field-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
112
+ * by the tagged field.
113
+ *
114
+ * @param expression See {@link REGEX.checkAlgorithm }.
115
+ * @param path See {@link DBC.decInvariant }.
116
+ * @param dbc See {@link DBC.decInvariant }.
117
+ * @param hint See {@link DBC.decInvariant }.
118
+ * @returns See {@link DBC.decInvariant }. */
119
+ public static INVARIANT(
120
+ expression: RegExp,
121
+ path: string | undefined = undefined,
122
+ hint: string | undefined = undefined,
123
+ dbc: string | undefined = undefined,
124
+ ) {
125
+ return DBC.createINVARIANT(REGEX, [expression], dbc, path, hint);
126
+ }
127
+ // #endregion Condition checking.
128
+ // #region Referenced Condition checking.
129
+ //
130
+ // For usage in dynamic scenarios (like with AE-DBC).
131
+ //
132
+ /**
133
+ * Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.equivalent }.
134
+ *
135
+ * @param toCheck See {@link REGEX.checkAlgorithm }.
136
+ *
137
+ * @returns See {@link EQ.checkAlgorithm}. */
138
+ public check(toCheck: unknown | null | undefined) {
139
+ return REGEX.checkAlgorithm(toCheck, this.expression);
140
+ }
141
+ /**
142
+ * Type-safe check that validates a value against a regular expression and returns it as the specified type.
143
+ *
144
+ * @param toCheck The value to check against the regular expression.
145
+ * @param expression The regular expression to validate against.
146
+ * @param hint Optional hint message to include in the error if validation fails.
147
+ * @param id Optional identifier to include in the error message.
148
+ *
149
+ * @returns The validated value cast to the CANDIDATE type.
150
+ *
151
+ * @throws {@link DBC.Infringement} if the value does not match the regular expression. */
152
+ public static tsCheck<CANDIDATE = unknown>(
153
+ toCheck: any,
154
+ expression: RegExp,
155
+ hint: string | undefined = undefined,
156
+ id: string | undefined = undefined,
157
+ dbc: string | undefined = undefined,
158
+ ): CANDIDATE {
159
+ const result = REGEX.checkAlgorithm(toCheck, expression);
160
+ if (result === true) {
161
+ return toCheck;
162
+ }
163
+ DBC.reportTsCheckInfringement(
164
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
165
+ dbc,
166
+ );
167
+ return toCheck as CANDIDATE;
168
+ }
169
+ /**
170
+ * Creates this {@link REGEX } by setting the protected property {@link REGEX.expression } used by {@link REGEX.check }.
171
+ *
172
+ * @param expression See {@link REGEX.check }. */
173
+ public constructor(protected expression: RegExp) {
174
+ super();
175
+ }
176
+ // #endregion Referenced Condition checking.
177
+ // #region In-Method checking.
178
+ /**
179
+ * Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.expression }.
180
+ *
181
+ * @param toCheck See {@link REGEX.checkAlgorithm}.
182
+ * @param expression See {@link REGEX.checkAlgorithm}.
183
+ */
184
+ public static check(
185
+ toCheck: unknown | null | undefined,
186
+ expression: RegExp,
187
+ dbc: string | undefined = undefined,
188
+ ) {
189
+ const checkResult = REGEX.checkAlgorithm(toCheck, expression);
190
+ if (typeof checkResult === "string") {
191
+ DBC.reportTsCheckInfringement(checkResult, dbc);
192
+ }
193
+ }
194
+ // #endregion In-Method checking.
195
+ }