xdbc 1.0.93 → 1.0.95
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/.parcel-cache/bf96c58b6061a62a-BundleGraph +0 -0
- package/.parcel-cache/d7c812d65aeeac59-AssetGraph +0 -0
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/e81759c1f106a17f-RequestGraph +0 -0
- package/.parcel-cache/fe0db3c4eb428be2-AssetGraph +0 -0
- package/.parcel-cache/lock.mdb +0 -0
- package/.parcel-cache/snapshot-e81759c1f106a17f.txt +4609 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +40 -0
- package/FUNDING.yml +3 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/SECURITY.md +36 -0
- package/Test.html +1 -1
- package/__tests__/DBC/AE.test.ts +62 -0
- package/__tests__/DBC/EQ.test.ts +13 -0
- package/__tests__/DBC/GREATER.test.ts +29 -0
- package/__tests__/DBC/INSTANCE.test.ts +13 -0
- package/__tests__/DBC/JSON.OP.test.ts +47 -0
- package/__tests__/DBC/JSON.Parse.test.ts +17 -0
- package/__tests__/DBC/OR.test.ts +14 -0
- package/__tests__/DBC/REGEX.test.ts +13 -0
- package/__tests__/DBC/TYPE.test.ts +13 -0
- package/babel.rc +12 -0
- package/dist/DBC/AE.js +39 -23
- package/dist/DBC/COMPARISON/GREATER.js +22 -0
- package/dist/DBC/COMPARISON.js +99 -0
- package/dist/DBC/EQ.js +21 -7
- package/dist/DBC/GREATER.js +19 -6
- package/dist/DBC/INSTANCE.js +22 -9
- package/dist/DBC/JSON.OP.js +19 -7
- package/dist/DBC/JSON.Parse.js +19 -7
- package/dist/DBC/OR.js +35 -23
- package/dist/DBC/REGEX.js +21 -9
- package/dist/DBC/TYPE.js +19 -7
- package/dist/DBC.js +112 -39
- package/dist/Demo.js +267 -0
- package/dist/bundle.js +1329 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1640 -0
- package/docs/classes/DBC.DBC.html +98 -0
- package/docs/classes/DBC_AE.AE.html +160 -0
- package/docs/classes/DBC_EQ.EQ.html +131 -0
- package/docs/classes/DBC_GREATER.GREATER.html +139 -0
- package/docs/classes/DBC_INSTANCE.INSTANCE.html +130 -0
- package/docs/classes/DBC_JSON.OP.JSON_OP.html +138 -0
- package/docs/classes/DBC_JSON.Parse.JSON_Parse.html +129 -0
- package/docs/classes/DBC_OR.OR.html +137 -0
- package/docs/classes/DBC_REGEX.REGEX.html +136 -0
- package/docs/classes/DBC_TYPE.TYPE.html +130 -0
- package/docs/classes/Demo.Demo.html +14 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +1 -0
- package/docs/modules/DBC.html +1 -0
- package/docs/modules/DBC_AE.html +1 -0
- package/docs/modules/DBC_EQ.html +1 -0
- package/docs/modules/DBC_GREATER.html +1 -0
- package/docs/modules/DBC_INSTANCE.html +1 -0
- package/docs/modules/DBC_JSON.OP.html +1 -0
- package/docs/modules/DBC_JSON.Parse.html +1 -0
- package/docs/modules/DBC_OR.html +1 -0
- package/docs/modules/DBC_REGEX.html +1 -0
- package/docs/modules/DBC_TYPE.html +1 -0
- package/docs/modules/Demo.html +1 -0
- package/jest.config.ts +20 -0
- package/package.json +23 -5
- package/src/DBC/AE.ts +49 -24
- package/src/DBC/COMPARISON/GREATER.ts +38 -0
- package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +38 -0
- package/src/DBC/COMPARISON/LESS.ts +38 -0
- package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +38 -0
- package/src/DBC/COMPARISON.ts +150 -0
- package/src/DBC/EQ.ts +26 -8
- package/src/DBC/GREATER.ts +30 -7
- package/src/DBC/INSTANCE.ts +26 -10
- package/src/DBC/JSON.OP.ts +29 -8
- package/src/DBC/JSON.Parse.ts +24 -8
- package/src/DBC/OR.ts +42 -24
- package/src/DBC/REGEX.ts +26 -10
- package/src/DBC/TYPE.ts +24 -8
- package/src/DBC.ts +138 -46
- package/src/Demo.ts +211 -0
- package/tsconfig.json +3 -1
- package/typedoc.json +16 -0
- package/webpack.config.js +26 -0
- package/dist/DBC.min.js +0 -2
- package/dist/test.js +0 -110
- package/src/test.ts +0 -61
- package/test.js +0 -14
- package/test.ts +0 -11
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COMPARISON } from "../COMPARISON";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export class GREATER extends COMPARISON {
|
|
4
|
+
/** See {@link COMPARISON.PRE }. */
|
|
5
|
+
public static override PRE(
|
|
6
|
+
equivalent,
|
|
7
|
+
equalityPermitted = false,
|
|
8
|
+
invert = false,
|
|
9
|
+
path: string = undefined,
|
|
10
|
+
dbc = "WaXCode.DBC",
|
|
11
|
+
) {
|
|
12
|
+
return COMPARISON.PRE(equivalent, false, false, path, dbc);
|
|
13
|
+
}
|
|
14
|
+
/** See {@link COMPARISON.POST }. */
|
|
15
|
+
public static override POST(
|
|
16
|
+
equivalent,
|
|
17
|
+
equalityPermitted = false,
|
|
18
|
+
invert = false,
|
|
19
|
+
path: string = undefined,
|
|
20
|
+
dbc = "WaXCode.DBC",
|
|
21
|
+
) {
|
|
22
|
+
return COMPARISON.POST(equivalent, false, false, path, dbc);
|
|
23
|
+
}
|
|
24
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
25
|
+
public static INVARIANT(
|
|
26
|
+
equivalent,
|
|
27
|
+
equalityPermitted = false,
|
|
28
|
+
invert = false,
|
|
29
|
+
path: string = undefined,
|
|
30
|
+
dbc = "WaXCode.DBC",
|
|
31
|
+
) {
|
|
32
|
+
return COMPARISON.INVARIANT(equivalent, false, false, path, dbc);
|
|
33
|
+
}
|
|
34
|
+
/** See {@link COMPARISON.constructor }. */
|
|
35
|
+
constructor(public equivalent) {
|
|
36
|
+
super(equivalent, false, false);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COMPARISON } from "../COMPARISON";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export class GREATER_OR_EQUAL extends COMPARISON {
|
|
4
|
+
/** See {@link COMPARISON.PRE }. */
|
|
5
|
+
public static override PRE(
|
|
6
|
+
equivalent,
|
|
7
|
+
equalityPermitted = false,
|
|
8
|
+
invert = false,
|
|
9
|
+
path: string = undefined,
|
|
10
|
+
dbc = "WaXCode.DBC",
|
|
11
|
+
) {
|
|
12
|
+
return COMPARISON.PRE(equivalent, true, false, path, dbc);
|
|
13
|
+
}
|
|
14
|
+
/** See {@link COMPARISON.POST }. */
|
|
15
|
+
public static override POST(
|
|
16
|
+
equivalent,
|
|
17
|
+
equalityPermitted = false,
|
|
18
|
+
invert = false,
|
|
19
|
+
path: string = undefined,
|
|
20
|
+
dbc = "WaXCode.DBC",
|
|
21
|
+
) {
|
|
22
|
+
return COMPARISON.POST(equivalent, true, false, path, dbc);
|
|
23
|
+
}
|
|
24
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
25
|
+
public static INVARIANT(
|
|
26
|
+
equivalent,
|
|
27
|
+
equalityPermitted = false,
|
|
28
|
+
invert = false,
|
|
29
|
+
path: string = undefined,
|
|
30
|
+
dbc = "WaXCode.DBC",
|
|
31
|
+
) {
|
|
32
|
+
return COMPARISON.INVARIANT(equivalent, true, false, path, dbc);
|
|
33
|
+
}
|
|
34
|
+
/** See {@link COMPARISON.constructor }. */
|
|
35
|
+
constructor(public equivalent) {
|
|
36
|
+
super(equivalent, true, false);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COMPARISON } from "../COMPARISON";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export class LESS extends COMPARISON {
|
|
4
|
+
/** See {@link COMPARISON.PRE }. */
|
|
5
|
+
public static override PRE(
|
|
6
|
+
equivalent,
|
|
7
|
+
equalityPermitted = false,
|
|
8
|
+
invert = false,
|
|
9
|
+
path: string = undefined,
|
|
10
|
+
dbc = "WaXCode.DBC",
|
|
11
|
+
) {
|
|
12
|
+
return COMPARISON.PRE(equivalent, false, true, path, dbc);
|
|
13
|
+
}
|
|
14
|
+
/** See {@link COMPARISON.POST }. */
|
|
15
|
+
public static override POST(
|
|
16
|
+
equivalent,
|
|
17
|
+
equalityPermitted = false,
|
|
18
|
+
invert = false,
|
|
19
|
+
path: string = undefined,
|
|
20
|
+
dbc = "WaXCode.DBC",
|
|
21
|
+
) {
|
|
22
|
+
return COMPARISON.POST(equivalent, false, true, path, dbc);
|
|
23
|
+
}
|
|
24
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
25
|
+
public static INVARIANT(
|
|
26
|
+
equivalent,
|
|
27
|
+
equalityPermitted = false,
|
|
28
|
+
invert = false,
|
|
29
|
+
path: string = undefined,
|
|
30
|
+
dbc = "WaXCode.DBC",
|
|
31
|
+
) {
|
|
32
|
+
return COMPARISON.INVARIANT(equivalent, false, true, path, dbc);
|
|
33
|
+
}
|
|
34
|
+
/** See {@link COMPARISON.constructor }. */
|
|
35
|
+
constructor(public equivalent) {
|
|
36
|
+
super(equivalent, false, true);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COMPARISON } from "../COMPARISON";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export class LESS_OR_EQUAL extends COMPARISON {
|
|
4
|
+
/** See {@link COMPARISON.PRE }. */
|
|
5
|
+
public static override PRE(
|
|
6
|
+
equivalent,
|
|
7
|
+
equalityPermitted = false,
|
|
8
|
+
invert = false,
|
|
9
|
+
path: string = undefined,
|
|
10
|
+
dbc = "WaXCode.DBC",
|
|
11
|
+
) {
|
|
12
|
+
return COMPARISON.PRE(equivalent, true, true, path, dbc);
|
|
13
|
+
}
|
|
14
|
+
/** See {@link COMPARISON.POST }. */
|
|
15
|
+
public static override POST(
|
|
16
|
+
equivalent,
|
|
17
|
+
equalityPermitted = false,
|
|
18
|
+
invert = false,
|
|
19
|
+
path: string = undefined,
|
|
20
|
+
dbc = "WaXCode.DBC",
|
|
21
|
+
) {
|
|
22
|
+
return COMPARISON.POST(equivalent, true, true, path, dbc);
|
|
23
|
+
}
|
|
24
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
25
|
+
public static INVARIANT(
|
|
26
|
+
equivalent,
|
|
27
|
+
equalityPermitted = false,
|
|
28
|
+
invert = false,
|
|
29
|
+
path: string = undefined,
|
|
30
|
+
dbc = "WaXCode.DBC",
|
|
31
|
+
) {
|
|
32
|
+
return COMPARISON.INVARIANT(equivalent, true, true, path, dbc);
|
|
33
|
+
}
|
|
34
|
+
/** See {@link COMPARISON.constructor }. */
|
|
35
|
+
constructor(public equivalent) {
|
|
36
|
+
super(equivalent, true, true);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining a comparison between two {@link object }s.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
+
export class COMPARISON extends DBC {
|
|
8
|
+
// #region Condition checking.
|
|
9
|
+
/**
|
|
10
|
+
* Does a comparison between the {@link object } **toCheck** and the **equivalent**.
|
|
11
|
+
*
|
|
12
|
+
* @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
|
|
13
|
+
* @param equivalent The {@link object } the one **toCheck** has to be equal to in order for this {@link DBC } to be
|
|
14
|
+
* fulfilled.
|
|
15
|
+
*
|
|
16
|
+
* @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
|
|
17
|
+
static checkAlgorithm(toCheck, equivalent, equalityPermitted, invert) {
|
|
18
|
+
if (equalityPermitted && !invert && toCheck < equivalent) {
|
|
19
|
+
return `Value has to to be greater than or equal to "${equivalent}"`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (equalityPermitted && invert && toCheck > equivalent) {
|
|
23
|
+
return `Value must not to be less than or equal to "${equivalent}"`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!equalityPermitted && !invert && toCheck <= equivalent) {
|
|
27
|
+
return `Value has to to be greater than "${equivalent}"`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!equalityPermitted && invert && toCheck >= equivalent) {
|
|
31
|
+
return `Value must not to be less than "${equivalent}"`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A parameter-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
38
|
+
* by the tagged parameter.
|
|
39
|
+
*
|
|
40
|
+
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
41
|
+
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
42
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
43
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
44
|
+
*
|
|
45
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
46
|
+
static PRE(
|
|
47
|
+
equivalent,
|
|
48
|
+
equalityPermitted = false,
|
|
49
|
+
invert = false,
|
|
50
|
+
path: string = undefined,
|
|
51
|
+
dbc = "WaXCode.DBC",
|
|
52
|
+
) {
|
|
53
|
+
return DBC.decPrecondition(
|
|
54
|
+
(value, target, methodName, parameterIndex) => {
|
|
55
|
+
return COMPARISON.checkAlgorithm(
|
|
56
|
+
value,
|
|
57
|
+
equivalent,
|
|
58
|
+
equalityPermitted,
|
|
59
|
+
invert,
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
dbc,
|
|
63
|
+
path,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A method-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
68
|
+
* by the tagged method's returnvalue.
|
|
69
|
+
*
|
|
70
|
+
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
71
|
+
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
72
|
+
* @param path See {@link DBC.Postcondition }.
|
|
73
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
74
|
+
*
|
|
75
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
76
|
+
static POST(
|
|
77
|
+
equivalent,
|
|
78
|
+
equalityPermitted = false,
|
|
79
|
+
invert = false,
|
|
80
|
+
path: string = undefined,
|
|
81
|
+
dbc = "WaXCode.DBC",
|
|
82
|
+
) {
|
|
83
|
+
return DBC.decPostcondition(
|
|
84
|
+
(value, target, propertyKey) => {
|
|
85
|
+
return COMPARISON.checkAlgorithm(
|
|
86
|
+
value,
|
|
87
|
+
equalityPermitted,
|
|
88
|
+
equivalent,
|
|
89
|
+
invert,
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
dbc,
|
|
93
|
+
path,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A field-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
98
|
+
* by the tagged field.
|
|
99
|
+
*
|
|
100
|
+
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
101
|
+
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
102
|
+
* @param path See {@link DBC.decInvariant }.
|
|
103
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
104
|
+
*
|
|
105
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
106
|
+
static INVARIANT(
|
|
107
|
+
equivalent,
|
|
108
|
+
equalityPermitted = false,
|
|
109
|
+
invert = false,
|
|
110
|
+
path: string = undefined,
|
|
111
|
+
dbc = "WaXCode.DBC",
|
|
112
|
+
) {
|
|
113
|
+
return DBC.decInvariant(
|
|
114
|
+
[new COMPARISON(equivalent, equalityPermitted, invert)],
|
|
115
|
+
path,
|
|
116
|
+
dbc,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
// #endregion Condition checking.
|
|
120
|
+
// #region Referenced Condition checking.
|
|
121
|
+
// #region Dynamic usage.
|
|
122
|
+
/**
|
|
123
|
+
* Invokes the {@link COMPARISON.checkAlgorithm } passing the value **toCheck**, {@link COMPARISON.equivalent } and {@link COMPARISON.invert }.
|
|
124
|
+
*
|
|
125
|
+
* @param toCheck See {@link COMPARISON.checkAlgorithm }.
|
|
126
|
+
*
|
|
127
|
+
* @returns See {@link COMPARISON.checkAlgorithm}. */
|
|
128
|
+
public check(toCheck) {
|
|
129
|
+
return COMPARISON.checkAlgorithm(
|
|
130
|
+
toCheck,
|
|
131
|
+
this.equivalent,
|
|
132
|
+
this.equalityPermitted,
|
|
133
|
+
this.invert,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Creates this {@link COMPARISON } by setting the protected property {@link COMPARISON.equivalent }, {@link COMPARISON.equalityPermitted } and {@link COMPARISON.invert } used by {@link COMPARISON.check }.
|
|
138
|
+
*
|
|
139
|
+
* @param equivalent See {@link COMPARISON.check }.
|
|
140
|
+
* @param equalityPermitted See {@link COMPARISON.check }.
|
|
141
|
+
* @param invert See {@link COMPARISON.check }. */
|
|
142
|
+
constructor(
|
|
143
|
+
public equivalent,
|
|
144
|
+
public equalityPermitted = false,
|
|
145
|
+
public invert = false,
|
|
146
|
+
) {
|
|
147
|
+
super();
|
|
148
|
+
}
|
|
149
|
+
// #endregion Dynamic usage.
|
|
150
|
+
}
|
package/src/DBC/EQ.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DBC } from "../DBC
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
2
|
/**
|
|
3
3
|
* A {@link DBC } defining that two {@link object }s gotta be equal.
|
|
4
4
|
*
|
|
@@ -7,13 +7,13 @@ import { DBC } from "../DBC.js";
|
|
|
7
7
|
export class EQ extends DBC {
|
|
8
8
|
// #region Condition checking.
|
|
9
9
|
/**
|
|
10
|
-
* Checks if the value
|
|
10
|
+
* Checks if the value **toCheck** is equal to the specified **equivalent**.
|
|
11
11
|
*
|
|
12
|
-
* @param toCheck The value that has to be equal to it's possible
|
|
13
|
-
* @param equivalent The {@link object } the one
|
|
12
|
+
* @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
|
|
13
|
+
* @param equivalent The {@link object } the one **toCheck** has to be equal to in order for this {@link DBC } to be
|
|
14
14
|
* fulfilled.
|
|
15
15
|
*
|
|
16
|
-
* @returns TRUE if the value
|
|
16
|
+
* @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
|
|
17
17
|
public static checkAlgorithm(
|
|
18
18
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
19
19
|
toCheck: any,
|
|
@@ -91,19 +91,37 @@ export class EQ extends DBC {
|
|
|
91
91
|
path,
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
96
|
+
* by the tagged field.
|
|
97
|
+
*
|
|
98
|
+
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
99
|
+
* @param path See {@link DBC.decInvariant }.
|
|
100
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
101
|
+
*
|
|
102
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
103
|
+
public static INVARIANT(
|
|
104
|
+
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
105
|
+
equivalent: any,
|
|
106
|
+
invert = false,
|
|
107
|
+
path: string | undefined = undefined,
|
|
108
|
+
dbc = "WaXCode.DBC",
|
|
109
|
+
) {
|
|
110
|
+
return DBC.decInvariant([new EQ(equivalent, invert)], path, dbc);
|
|
111
|
+
}
|
|
94
112
|
// #endregion Condition checking.
|
|
95
113
|
// #region Referenced Condition checking.
|
|
96
114
|
//
|
|
97
115
|
// For usage in dynamic scenarios (like with AE-DBC).
|
|
98
116
|
//
|
|
99
117
|
/**
|
|
100
|
-
* Invokes the {@link EQ.checkAlgorithm } passing the value
|
|
118
|
+
* Invokes the {@link EQ.checkAlgorithm } passing the value **toCheck**, {@link EQ.equivalent } and {@link EQ.invert }.
|
|
101
119
|
*
|
|
102
120
|
* @param toCheck See {@link EQ.checkAlgorithm }.
|
|
103
121
|
*
|
|
104
122
|
* @returns See {@link EQ.checkAlgorithm}. */
|
|
105
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
106
|
-
public
|
|
123
|
+
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
124
|
+
public check(toCheck: any) {
|
|
107
125
|
return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
|
|
108
126
|
}
|
|
109
127
|
/**
|
package/src/DBC/GREATER.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DBC } from "../DBC
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
2
|
/**
|
|
3
3
|
* A {@link DBC } defining that two {@link object }s gotta be equal.
|
|
4
4
|
*
|
|
@@ -7,13 +7,13 @@ import { DBC } from "../DBC.js";
|
|
|
7
7
|
export class GREATER extends DBC {
|
|
8
8
|
// #region Condition checking.
|
|
9
9
|
/**
|
|
10
|
-
* Checks if the value
|
|
10
|
+
* Checks if the value **toCheck** is equal to the specified **equivalent**.
|
|
11
11
|
*
|
|
12
|
-
* @param toCheck The value that has to be equal to it's possible
|
|
13
|
-
* @param equivalent The {@link object } the one
|
|
12
|
+
* @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
|
|
13
|
+
* @param equivalent The {@link object } the one **toCheck** has to be equal to in order for this {@link DBC } to be
|
|
14
14
|
* fulfilled.
|
|
15
15
|
*
|
|
16
|
-
* @returns TRUE if the value
|
|
16
|
+
* @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
|
|
17
17
|
static checkAlgorithm(toCheck, equivalent, equalityPermitted, invert) {
|
|
18
18
|
if (equalityPermitted && !invert && toCheck < equivalent) {
|
|
19
19
|
return `Value has to to be greater than or equal to "${equivalent}"`;
|
|
@@ -93,16 +93,39 @@ export class GREATER extends DBC {
|
|
|
93
93
|
path,
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* A field-decorator factory using the {@link GREATER.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
98
|
+
* by the tagged field.
|
|
99
|
+
*
|
|
100
|
+
* @param equivalent See {@link GREATER.checkAlgorithm }.
|
|
101
|
+
* @param equalityPermitted See {@link GREATER.checkAlgorithm }.
|
|
102
|
+
* @param path See {@link DBC.decInvariant }.
|
|
103
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
104
|
+
*
|
|
105
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
106
|
+
static INVARIANT(
|
|
107
|
+
equivalent,
|
|
108
|
+
equalityPermitted = false,
|
|
109
|
+
invert = false,
|
|
110
|
+
path: string = undefined,
|
|
111
|
+
dbc = "WaXCode.DBC",
|
|
112
|
+
) {
|
|
113
|
+
return DBC.decInvariant(
|
|
114
|
+
[new GREATER(equivalent, equalityPermitted, invert)],
|
|
115
|
+
path,
|
|
116
|
+
dbc,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
96
119
|
// #endregion Condition checking.
|
|
97
120
|
// #region Referenced Condition checking.
|
|
98
121
|
// #region Dynamic usage.
|
|
99
122
|
/**
|
|
100
|
-
* Invokes the {@link GREATER.checkAlgorithm } passing the value
|
|
123
|
+
* Invokes the {@link GREATER.checkAlgorithm } passing the value **toCheck**, {@link GREATER.equivalent } and {@link GREATER.invert }.
|
|
101
124
|
*
|
|
102
125
|
* @param toCheck See {@link GREATER.checkAlgorithm }.
|
|
103
126
|
*
|
|
104
127
|
* @returns See {@link GREATER.checkAlgorithm}. */
|
|
105
|
-
public
|
|
128
|
+
public check(toCheck) {
|
|
106
129
|
return GREATER.checkAlgorithm(
|
|
107
130
|
toCheck,
|
|
108
131
|
this.equivalent,
|
package/src/DBC/INSTANCE.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { DBC } from "../DBC
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
2
|
/**
|
|
3
3
|
* A {@link DBC } defining that the an {@link object }s gotta be an instance of a certain {@link INSTANCE.reference }.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
6
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
8
7
|
export class INSTANCE extends DBC {
|
|
9
8
|
/**
|
|
10
|
-
* Checks if the value
|
|
9
|
+
* Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
|
|
11
10
|
*
|
|
12
|
-
* @param toCheck The value that has comply to the {@link RegExp }
|
|
13
|
-
* @param reference
|
|
14
|
-
*
|
|
11
|
+
* @param toCheck The value that has comply to the {@link RegExp } **expression** for this {@link DBC } to be fulfilled.
|
|
12
|
+
* @param reference The {@link RegExp } the one **toCheck** has comply to in order for this {@link DBC } to be
|
|
13
|
+
* fulfilled.
|
|
15
14
|
*
|
|
16
|
-
* @returns TRUE if the value
|
|
15
|
+
* @returns TRUE if the value **toCheck** is of the specified **type**, otherwise FALSE. */
|
|
17
16
|
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
18
17
|
public static checkAlgorithm(toCheck: any, reference: any): boolean | string {
|
|
19
18
|
if (!(toCheck instanceof reference)) {
|
|
@@ -81,19 +80,36 @@ export class INSTANCE extends DBC {
|
|
|
81
80
|
path,
|
|
82
81
|
);
|
|
83
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* A field-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
85
|
+
* by the tagged method's returnvalue.
|
|
86
|
+
*
|
|
87
|
+
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
88
|
+
* @param path See {@link DBC.decInvariant }.
|
|
89
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
90
|
+
*
|
|
91
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
92
|
+
public static INVARIANT(
|
|
93
|
+
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
94
|
+
reference: any,
|
|
95
|
+
path: string | undefined = undefined,
|
|
96
|
+
dbc = "WaXCode.DBC",
|
|
97
|
+
) {
|
|
98
|
+
return DBC.decInvariant([new INSTANCE(reference)], path, dbc);
|
|
99
|
+
}
|
|
84
100
|
// #endregion Condition checking.
|
|
85
101
|
// #region Referenced Condition checking.
|
|
86
102
|
//
|
|
87
103
|
// For usage in dynamic scenarios (like with AE-DBC).
|
|
88
104
|
//
|
|
89
105
|
/**
|
|
90
|
-
* Invokes the {@link INSTANCE.checkAlgorithm } passing the value
|
|
106
|
+
* Invokes the {@link INSTANCE.checkAlgorithm } passing the value **toCheck** and the {@link INSTANCE.reference } .
|
|
91
107
|
*
|
|
92
108
|
* @param toCheck See {@link INSTANCE.checkAlgorithm }.
|
|
93
109
|
*
|
|
94
110
|
* @returns See {@link INSTANCE.checkAlgorithm}. */
|
|
95
111
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
96
|
-
public
|
|
112
|
+
public check(toCheck: any) {
|
|
97
113
|
return INSTANCE.checkAlgorithm(toCheck, this.reference);
|
|
98
114
|
}
|
|
99
115
|
/**
|
package/src/DBC/JSON.OP.ts
CHANGED
|
@@ -7,16 +7,16 @@ import { DBC } from "../DBC";
|
|
|
7
7
|
export class JSON_OP extends DBC {
|
|
8
8
|
// #region Condition checking.
|
|
9
9
|
/**
|
|
10
|
-
* Checks if the object
|
|
10
|
+
* Checks if the object **toCheck** has the **necessaryProperties** of necessary type.
|
|
11
11
|
*
|
|
12
12
|
* @param toCheck The {@link object } to check for the necessary properties.
|
|
13
|
-
* @param necessaryProperties The { name : string, type : string }s defining the properties and type the {@link object } to
|
|
13
|
+
* @param necessaryProperties The **{ name : string, type : string }**s defining the properties and type the {@link object } to
|
|
14
14
|
* check needs to have.
|
|
15
|
-
* @param checkElements Indicates if
|
|
16
|
-
* Elements will only be checked if
|
|
15
|
+
* @param checkElements Indicates if **toCheck** is an iterable object of which all elements have to be checked.
|
|
16
|
+
* Elements will only be checked if **toCheck** is iterable, otherwise **toCheck** itself
|
|
17
17
|
* will be checked.
|
|
18
18
|
*
|
|
19
|
-
* @returns TRUE if the value
|
|
19
|
+
* @returns TRUE if the value **toCheck** or it's elements, if **checkElements** is TRUE, has all **necessaryProperties**, otherwise a {@link string } to report the infringement. */
|
|
20
20
|
public static checkAlgorithm(
|
|
21
21
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
22
22
|
toCheck: any,
|
|
@@ -120,19 +120,40 @@ export class JSON_OP extends DBC {
|
|
|
120
120
|
path,
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
125
|
+
* by the tagged field.
|
|
126
|
+
*
|
|
127
|
+
* @param expression See {@link JSON.checkAlgorithm }.
|
|
128
|
+
* @param path See {@link DBC.decInvariant }.
|
|
129
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
130
|
+
*
|
|
131
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
132
|
+
public static INVARIANT(
|
|
133
|
+
necessaryProperties: Array<{ name: string; type: string }>,
|
|
134
|
+
checkElements = false,
|
|
135
|
+
path: string | undefined = undefined,
|
|
136
|
+
dbc = "WaXCode.DBC",
|
|
137
|
+
) {
|
|
138
|
+
return DBC.decInvariant(
|
|
139
|
+
[new JSON_OP(necessaryProperties, checkElements)],
|
|
140
|
+
path,
|
|
141
|
+
dbc,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
123
144
|
// #endregion Condition checking.
|
|
124
145
|
// #region Referenced Condition checking.
|
|
125
146
|
//
|
|
126
147
|
// For usage in dynamic scenarios (like with AE-DBC).
|
|
127
148
|
//
|
|
128
149
|
/**
|
|
129
|
-
* Invokes the {@link JSON_OP.checkAlgorithm } passing the value
|
|
150
|
+
* Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
|
|
130
151
|
*
|
|
131
152
|
* @param toCheck See {@link JSON_OP.checkAlgorithm }.
|
|
132
153
|
*
|
|
133
154
|
* @returns See {@link JSON_OP.checkAlgorithm}. */
|
|
134
155
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
135
|
-
public
|
|
156
|
+
public check(toCheck: any) {
|
|
136
157
|
return JSON_OP.checkAlgorithm(
|
|
137
158
|
toCheck,
|
|
138
159
|
this.necessaryProperties,
|
|
@@ -153,7 +174,7 @@ export class JSON_OP extends DBC {
|
|
|
153
174
|
// #endregion Referenced Condition checking.
|
|
154
175
|
// #region In-Method checking.
|
|
155
176
|
/**
|
|
156
|
-
* Invokes the {@link JSON_OP.checkAlgorithm } passing the value
|
|
177
|
+
* Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
|
|
157
178
|
*
|
|
158
179
|
* @param toCheck See {@link JSON_OP.checkAlgorithm} }.
|
|
159
180
|
* @param necessaryProperties See {@link JSON_OP.checkAlgorithm} }.
|
package/src/DBC/JSON.Parse.ts
CHANGED
|
@@ -7,13 +7,13 @@ import { DBC } from "../DBC";
|
|
|
7
7
|
export class JSON_Parse extends DBC {
|
|
8
8
|
// #region Condition checking.
|
|
9
9
|
/**
|
|
10
|
-
* Tries to {@link JSON.parse } the {@link string }
|
|
10
|
+
* Tries to {@link JSON.parse } the {@link string } **toCheck** invoking the **receptor** with the result, if so.
|
|
11
11
|
*
|
|
12
12
|
* @param toCheck The {@link string } to be {@link JSON.parse }d.
|
|
13
|
-
* @param receptor The ( json : object ) => void to receive the {@link JSON.parse }d {@link string }
|
|
14
|
-
*
|
|
13
|
+
* @param receptor The **( json : object ) => void** to receive the {@link JSON.parse }d {@link string } **toCheck**.
|
|
14
|
+
* check needs to have.
|
|
15
15
|
*
|
|
16
|
-
* @returns TRUE if the value
|
|
16
|
+
* @returns TRUE if the value **toCheck** is a valid JSON, otherwise a {@link string } to report the infringement. */
|
|
17
17
|
public static checkAlgorithm(
|
|
18
18
|
toCheck: string,
|
|
19
19
|
receptor: (json: object) => void,
|
|
@@ -91,19 +91,35 @@ export class JSON_Parse extends DBC {
|
|
|
91
91
|
path,
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
96
|
+
* by the tagged field.
|
|
97
|
+
*
|
|
98
|
+
* @param expression See {@link JSON.checkAlgorithm }.
|
|
99
|
+
* @param path See {@link DBC.decInvariant }.
|
|
100
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
101
|
+
*
|
|
102
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
103
|
+
public static INVARIANT(
|
|
104
|
+
receptor: (json: object) => void,
|
|
105
|
+
path: string | undefined = undefined,
|
|
106
|
+
dbc = "WaXCode.DBC",
|
|
107
|
+
) {
|
|
108
|
+
return DBC.decInvariant([new JSON_Parse(receptor)], path, dbc);
|
|
109
|
+
}
|
|
94
110
|
// #endregion Condition checking.
|
|
95
111
|
// #region Referenced Condition checking.
|
|
96
112
|
//
|
|
97
113
|
// For usage in dynamic scenarios (like with AE-DBC).
|
|
98
114
|
//
|
|
99
115
|
/**
|
|
100
|
-
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value
|
|
116
|
+
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck** and {@link JSON_Parse.receptor }.
|
|
101
117
|
*
|
|
102
118
|
* @param toCheck See {@link JSON_Parse.checkAlgorithm }.
|
|
103
119
|
*
|
|
104
120
|
* @returns See {@link JSON_Parse.checkAlgorithm}. */
|
|
105
121
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
106
|
-
public
|
|
122
|
+
public check(toCheck: any) {
|
|
107
123
|
return JSON_Parse.checkAlgorithm(toCheck, this.receptor);
|
|
108
124
|
}
|
|
109
125
|
/**
|
|
@@ -111,13 +127,13 @@ export class JSON_Parse extends DBC {
|
|
|
111
127
|
*
|
|
112
128
|
* @param necessaryProperties See {@link JSON_Parse.check }.
|
|
113
129
|
* @param checkElements See {@link JSON_Parse.check }. */
|
|
114
|
-
public constructor(public receptor: (json: object) => void) {
|
|
130
|
+
public constructor(public receptor: (json: object) => void = undefined) {
|
|
115
131
|
super();
|
|
116
132
|
}
|
|
117
133
|
// #endregion Referenced Condition checking.
|
|
118
134
|
// #region In-Method checking.
|
|
119
135
|
/**
|
|
120
|
-
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value
|
|
136
|
+
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck**, {@link JSON_Parse.necessaryProperties } and {@link JSON_Parse.checkElements }.
|
|
121
137
|
*
|
|
122
138
|
* @param toCheck See {@link JSON_Parse.checkAlgorithm} }.
|
|
123
139
|
* @param necessaryProperties See {@link JSON_Parse.checkAlgorithm} }.
|