xdbc 1.0.217 → 1.0.219
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.
- package/.gitattributes +16 -8
- package/.vscode/settings.json +3 -3
- package/.vscode/tasks.json +23 -23
- package/ASSESSMENT.md +249 -0
- package/README.md +538 -408
- package/__tests__/DBC/AE.test.ts +62 -62
- package/__tests__/DBC/ARRAY.test.ts +91 -91
- package/__tests__/DBC/DEFINED.test.ts +53 -53
- package/__tests__/DBC/DOM.test.ts +786 -0
- package/__tests__/DBC/Decorators.test.ts +367 -367
- package/__tests__/DBC/EQ.test.ts +13 -13
- package/__tests__/DBC/GREATER.test.ts +31 -31
- package/__tests__/DBC/HasAttribute.test.ts +60 -60
- package/__tests__/DBC/IF.test.ts +62 -62
- package/__tests__/DBC/INSTANCE.test.ts +13 -13
- package/__tests__/DBC/JSON.OP.test.ts +47 -47
- package/__tests__/DBC/JSON.Parse.test.ts +17 -17
- package/__tests__/DBC/OR.test.ts +14 -14
- package/__tests__/DBC/PLAIN_OBJECT.test.ts +109 -109
- package/__tests__/DBC/REGEX.test.ts +17 -17
- package/__tests__/DBC/TYPE.test.ts +13 -13
- package/__tests__/DBC/UNDEFINED.test.ts +45 -45
- package/__tests__/DBC/ZOD.test.ts +54 -54
- package/__tests__/DBC/onInfringement.test.ts +262 -0
- package/biome.json +45 -40
- package/dist/DBC/AE.js +172 -0
- package/dist/DBC/ARR/PLAIN_OBJECT.d.ts +0 -3
- package/dist/DBC/ARR/PLAIN_OBJECT.js +95 -0
- package/dist/DBC/ARRAY.d.ts +0 -3
- package/dist/DBC/ARRAY.js +90 -0
- package/dist/DBC/COMPARISON/GREATER.js +21 -0
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON/LESS.js +21 -0
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON.js +98 -0
- package/dist/DBC/DEFINED.js +87 -0
- package/dist/DBC/DOM.d.ts +123 -0
- package/dist/DBC/DOM.js +362 -0
- package/dist/DBC/EQ/DIFFERENT.js +34 -0
- package/dist/DBC/EQ.js +101 -0
- package/dist/DBC/GREATER.js +99 -0
- package/dist/DBC/HasAttribute.js +101 -0
- package/dist/DBC/IF.js +96 -0
- package/dist/DBC/INSTANCE.js +122 -0
- package/dist/DBC/JSON.OP.js +120 -0
- package/dist/DBC/JSON.Parse.js +104 -0
- package/dist/DBC/OR.js +125 -0
- package/dist/DBC/REGEX.js +136 -0
- package/dist/DBC/TYPE.js +112 -0
- package/dist/DBC/UNDEFINED.js +87 -0
- package/dist/DBC/ZOD.js +99 -0
- package/dist/DBC.d.ts +18 -4
- package/dist/DBC.js +645 -0
- package/dist/Demo.d.ts +10 -0
- package/dist/Demo.js +713 -0
- package/dist/Test.html +18 -0
- package/dist/bundle.js +6140 -405
- package/dist/index.d.ts +22 -0
- package/dist/index.html +18 -0
- package/dist/index.js +22 -0
- package/docs/assets/highlight.css +22 -22
- package/docs/assets/icons.js +17 -17
- package/docs/assets/main.js +60 -60
- package/docs/assets/style.css +1640 -1640
- package/docs/classes/DBC.DBC.html +98 -98
- package/docs/classes/DBC_AE.AE.html +160 -160
- package/docs/classes/DBC_EQ.EQ.html +131 -131
- package/docs/classes/DBC_GREATER.GREATER.html +139 -139
- package/docs/classes/DBC_INSTANCE.INSTANCE.html +130 -130
- package/docs/classes/DBC_JSON.OP.JSON_OP.html +138 -138
- package/docs/classes/DBC_JSON.Parse.JSON_Parse.html +129 -129
- package/docs/classes/DBC_OR.OR.html +137 -137
- package/docs/classes/DBC_REGEX.REGEX.html +136 -136
- package/docs/classes/DBC_TYPE.TYPE.html +130 -130
- package/docs/classes/Demo.Demo.html +14 -14
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +1 -1
- package/docs/modules/DBC.html +1 -1
- package/docs/modules/DBC_AE.html +1 -1
- package/docs/modules/DBC_EQ.html +1 -1
- package/docs/modules/DBC_GREATER.html +1 -1
- package/docs/modules/DBC_INSTANCE.html +1 -1
- package/docs/modules/DBC_JSON.OP.html +1 -1
- package/docs/modules/DBC_JSON.Parse.html +1 -1
- package/docs/modules/DBC_OR.html +1 -1
- package/docs/modules/DBC_REGEX.html +1 -1
- package/docs/modules/DBC_TYPE.html +1 -1
- package/docs/modules/Demo.html +1 -1
- package/jest.config.js +32 -32
- package/package.json +71 -55
- package/src/DBC/AE.ts +269 -288
- package/src/DBC/ARR/PLAIN_OBJECT.ts +122 -133
- package/src/DBC/ARRAY.ts +117 -127
- package/src/DBC/COMPARISON/GREATER.ts +41 -46
- package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +41 -45
- package/src/DBC/COMPARISON/LESS.ts +41 -45
- package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +41 -45
- package/src/DBC/COMPARISON.ts +149 -159
- package/src/DBC/DEFINED.ts +117 -122
- package/src/DBC/DOM.ts +453 -0
- package/src/DBC/EQ/DIFFERENT.ts +51 -57
- package/src/DBC/EQ.ts +154 -163
- package/src/DBC/HasAttribute.ts +149 -154
- package/src/DBC/IF.ts +173 -179
- package/src/DBC/INSTANCE.ts +168 -171
- package/src/DBC/JSON.OP.ts +178 -186
- package/src/DBC/JSON.Parse.ts +150 -157
- package/src/DBC/OR.ts +183 -187
- package/src/DBC/REGEX.ts +195 -196
- package/src/DBC/TYPE.ts +142 -149
- package/src/DBC/UNDEFINED.ts +115 -117
- package/src/DBC/ZOD.ts +130 -135
- package/src/DBC.ts +902 -904
- package/src/Demo.ts +537 -404
- package/src/index.ts +22 -0
- package/tsconfig.json +18 -18
- package/tsconfig.test.json +7 -7
- package/typedoc.json +16 -16
- package/webpack.config.js +27 -27
- 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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @param
|
|
96
|
-
*
|
|
97
|
-
* @
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @param
|
|
118
|
-
* @
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
*
|
|
149
|
-
* @
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const checkResult = REGEX.checkAlgorithm(toCheck, expression);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
}
|