xdbc 1.0.198 → 1.0.199
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/Test.html +1 -1
- package/dist/DBC/COMPARISON.js +99 -99
- package/dist/DBC/EQ.js +100 -117
- package/dist/DBC/INSTANCE.js +93 -113
- package/dist/DBC/OR.js +113 -130
- package/dist/DBC/TYPE.js +87 -107
- package/dist/DBC.js +336 -420
- package/dist/Demo.js +290 -420
- package/dist/bundle.js +4 -4
- package/package.json +2 -3
- package/src/DBC/COMPARISON/GREATER.ts +5 -4
- package/tsconfig.json +1 -3
package/Test.html
CHANGED
package/dist/DBC/COMPARISON.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
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
|
-
if (equalityPermitted && invert && toCheck > equivalent) {
|
|
22
|
-
return `Value
|
|
23
|
-
}
|
|
24
|
-
if (!equalityPermitted && !invert && toCheck <= equivalent) {
|
|
25
|
-
return `Value has to to be greater than "${equivalent}"`;
|
|
26
|
-
}
|
|
27
|
-
if (!equalityPermitted && invert && toCheck >= equivalent) {
|
|
28
|
-
return `Value
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A parameter-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
34
|
-
* by the tagged parameter.
|
|
35
|
-
*
|
|
36
|
-
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
37
|
-
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
38
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
39
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
40
|
-
*
|
|
41
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
42
|
-
static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
43
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
44
|
-
return COMPARISON.checkAlgorithm(value, equivalent, equalityPermitted, invert);
|
|
45
|
-
}, dbc, path);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A method-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
49
|
-
* by the tagged method's returnvalue.
|
|
50
|
-
*
|
|
51
|
-
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
52
|
-
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
53
|
-
* @param path See {@link DBC.Postcondition }.
|
|
54
|
-
* @param dbc See {@link DBC.decPostcondition }.
|
|
55
|
-
*
|
|
56
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
57
|
-
static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
58
|
-
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
59
|
-
return COMPARISON.checkAlgorithm(value, equalityPermitted, equivalent, invert);
|
|
60
|
-
}, dbc, path);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A field-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
64
|
-
* by the tagged field.
|
|
65
|
-
*
|
|
66
|
-
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
67
|
-
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
68
|
-
* @param path See {@link DBC.decInvariant }.
|
|
69
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
70
|
-
*
|
|
71
|
-
* @returns See {@link DBC.decInvariant }. */
|
|
72
|
-
static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
73
|
-
return DBC.decInvariant([new COMPARISON(equivalent, equalityPermitted, invert)], path, dbc);
|
|
74
|
-
}
|
|
75
|
-
// #endregion Condition checking.
|
|
76
|
-
// #region Referenced Condition checking.
|
|
77
|
-
// #region Dynamic usage.
|
|
78
|
-
/**
|
|
79
|
-
* Invokes the {@link COMPARISON.checkAlgorithm } passing the value **toCheck**, {@link COMPARISON.equivalent } and {@link COMPARISON.invert }.
|
|
80
|
-
*
|
|
81
|
-
* @param toCheck See {@link COMPARISON.checkAlgorithm }.
|
|
82
|
-
*
|
|
83
|
-
* @returns See {@link COMPARISON.checkAlgorithm}. */
|
|
84
|
-
check(toCheck) {
|
|
85
|
-
return COMPARISON.checkAlgorithm(toCheck, this.equivalent, this.equalityPermitted, this.invert);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates this {@link COMPARISON } by setting the protected property {@link COMPARISON.equivalent }, {@link COMPARISON.equalityPermitted } and {@link COMPARISON.invert } used by {@link COMPARISON.check }.
|
|
89
|
-
*
|
|
90
|
-
* @param equivalent See {@link COMPARISON.check }.
|
|
91
|
-
* @param equalityPermitted See {@link COMPARISON.check }.
|
|
92
|
-
* @param invert See {@link COMPARISON.check }. */
|
|
93
|
-
constructor(equivalent, equalityPermitted = false, invert = false) {
|
|
94
|
-
super();
|
|
95
|
-
this.equivalent = equivalent;
|
|
96
|
-
this.equalityPermitted = equalityPermitted;
|
|
97
|
-
this.invert = invert;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
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
|
+
if (equalityPermitted && invert && toCheck > equivalent) {
|
|
22
|
+
return `Value must not to be less than or equal to "${equivalent}"`;
|
|
23
|
+
}
|
|
24
|
+
if (!equalityPermitted && !invert && toCheck <= equivalent) {
|
|
25
|
+
return `Value has to to be greater than "${equivalent}"`;
|
|
26
|
+
}
|
|
27
|
+
if (!equalityPermitted && invert && toCheck >= equivalent) {
|
|
28
|
+
return `Value must not to be less than "${equivalent}"`;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A parameter-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
34
|
+
* by the tagged parameter.
|
|
35
|
+
*
|
|
36
|
+
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
37
|
+
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
38
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
39
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
40
|
+
*
|
|
41
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
42
|
+
static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
43
|
+
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
44
|
+
return COMPARISON.checkAlgorithm(value, equivalent, equalityPermitted, invert);
|
|
45
|
+
}, dbc, path);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A method-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
49
|
+
* by the tagged method's returnvalue.
|
|
50
|
+
*
|
|
51
|
+
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
52
|
+
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
53
|
+
* @param path See {@link DBC.Postcondition }.
|
|
54
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
55
|
+
*
|
|
56
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
57
|
+
static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
58
|
+
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
59
|
+
return COMPARISON.checkAlgorithm(value, equalityPermitted, equivalent, invert);
|
|
60
|
+
}, dbc, path);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A field-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
64
|
+
* by the tagged field.
|
|
65
|
+
*
|
|
66
|
+
* @param equivalent See {@link COMPARISON.checkAlgorithm }.
|
|
67
|
+
* @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
|
|
68
|
+
* @param path See {@link DBC.decInvariant }.
|
|
69
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
70
|
+
*
|
|
71
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
72
|
+
static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
73
|
+
return DBC.decInvariant([new COMPARISON(equivalent, equalityPermitted, invert)], path, dbc);
|
|
74
|
+
}
|
|
75
|
+
// #endregion Condition checking.
|
|
76
|
+
// #region Referenced Condition checking.
|
|
77
|
+
// #region Dynamic usage.
|
|
78
|
+
/**
|
|
79
|
+
* Invokes the {@link COMPARISON.checkAlgorithm } passing the value **toCheck**, {@link COMPARISON.equivalent } and {@link COMPARISON.invert }.
|
|
80
|
+
*
|
|
81
|
+
* @param toCheck See {@link COMPARISON.checkAlgorithm }.
|
|
82
|
+
*
|
|
83
|
+
* @returns See {@link COMPARISON.checkAlgorithm}. */
|
|
84
|
+
check(toCheck) {
|
|
85
|
+
return COMPARISON.checkAlgorithm(toCheck, this.equivalent, this.equalityPermitted, this.invert);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Creates this {@link COMPARISON } by setting the protected property {@link COMPARISON.equivalent }, {@link COMPARISON.equalityPermitted } and {@link COMPARISON.invert } used by {@link COMPARISON.check }.
|
|
89
|
+
*
|
|
90
|
+
* @param equivalent See {@link COMPARISON.check }.
|
|
91
|
+
* @param equalityPermitted See {@link COMPARISON.check }.
|
|
92
|
+
* @param invert See {@link COMPARISON.check }. */
|
|
93
|
+
constructor(equivalent, equalityPermitted = false, invert = false) {
|
|
94
|
+
super();
|
|
95
|
+
this.equivalent = equivalent;
|
|
96
|
+
this.equalityPermitted = equalityPermitted;
|
|
97
|
+
this.invert = invert;
|
|
98
|
+
}
|
|
99
|
+
}
|
package/dist/DBC/EQ.js
CHANGED
|
@@ -1,117 +1,100 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } defining that two {@link object }s gotta be equal.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
-
export class EQ extends DBC {
|
|
8
|
-
// #region Condition checking.
|
|
9
|
-
/**
|
|
10
|
-
* Checks if the value **toCheck** is equal to the specified **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(
|
|
18
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
19
|
-
toCheck, equivalent, invert) {
|
|
20
|
-
if (!invert && equivalent !== toCheck) {
|
|
21
|
-
return `Value has to to be equal to "${equivalent}"`;
|
|
22
|
-
}
|
|
23
|
-
if (invert && equivalent === toCheck) {
|
|
24
|
-
return `Value must not to be equal to "${equivalent}"`;
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
30
|
-
* by the tagged parameter.
|
|
31
|
-
*
|
|
32
|
-
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
33
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
34
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
35
|
-
*
|
|
36
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
37
|
-
static PRE(
|
|
38
|
-
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
39
|
-
equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
40
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
41
|
-
return EQ.checkAlgorithm(value, equivalent, invert);
|
|
42
|
-
}, dbc, path);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
46
|
-
* by the tagged method's returnvalue.
|
|
47
|
-
*
|
|
48
|
-
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
49
|
-
* @param path See {@link DBC.Postcondition }.
|
|
50
|
-
* @param dbc See {@link DBC.decPostcondition }.
|
|
51
|
-
*
|
|
52
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
53
|
-
static POST(
|
|
54
|
-
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
55
|
-
equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
56
|
-
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
57
|
-
return EQ.checkAlgorithm(value, equivalent, invert);
|
|
58
|
-
}, dbc, path);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
62
|
-
* by the tagged field.
|
|
63
|
-
*
|
|
64
|
-
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
65
|
-
* @param path See {@link DBC.decInvariant }.
|
|
66
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
67
|
-
*
|
|
68
|
-
* @returns See {@link DBC.decInvariant }. */
|
|
69
|
-
static INVARIANT(
|
|
70
|
-
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
71
|
-
equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
72
|
-
return DBC.decInvariant([new EQ(equivalent, invert)], path, dbc);
|
|
73
|
-
}
|
|
74
|
-
// #endregion Condition checking.
|
|
75
|
-
// #region Referenced Condition checking.
|
|
76
|
-
//
|
|
77
|
-
// For usage in dynamic scenarios (like with AE-DBC).
|
|
78
|
-
//
|
|
79
|
-
/**
|
|
80
|
-
* Invokes the {@link EQ.checkAlgorithm } passing the value **toCheck**, {@link EQ.equivalent } and {@link EQ.invert }.
|
|
81
|
-
*
|
|
82
|
-
* @param toCheck See {@link EQ.checkAlgorithm }.
|
|
83
|
-
*
|
|
84
|
-
* @returns See {@link EQ.checkAlgorithm}. */
|
|
85
|
-
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
86
|
-
check(toCheck) {
|
|
87
|
-
return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @param
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
throw new DBC.Infringement(result);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
|
|
108
|
-
*
|
|
109
|
-
* @param equivalent See {@link EQ.check }. */
|
|
110
|
-
constructor(
|
|
111
|
-
// biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
|
|
112
|
-
equivalent, invert = false) {
|
|
113
|
-
super();
|
|
114
|
-
this.equivalent = equivalent;
|
|
115
|
-
this.invert = invert;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that two {@link object }s gotta be equal.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
+
export class EQ extends DBC {
|
|
8
|
+
// #region Condition checking.
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the value **toCheck** is equal to the specified **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(
|
|
18
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
19
|
+
toCheck, equivalent, invert) {
|
|
20
|
+
if (!invert && equivalent !== toCheck) {
|
|
21
|
+
return `Value has to to be equal to "${equivalent}"`;
|
|
22
|
+
}
|
|
23
|
+
if (invert && equivalent === toCheck) {
|
|
24
|
+
return `Value must not to be equal to "${equivalent}"`;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
30
|
+
* by the tagged parameter.
|
|
31
|
+
*
|
|
32
|
+
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
33
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
34
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
35
|
+
*
|
|
36
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
37
|
+
static PRE(
|
|
38
|
+
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
39
|
+
equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
40
|
+
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
41
|
+
return EQ.checkAlgorithm(value, equivalent, invert);
|
|
42
|
+
}, dbc, path);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
46
|
+
* by the tagged method's returnvalue.
|
|
47
|
+
*
|
|
48
|
+
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
49
|
+
* @param path See {@link DBC.Postcondition }.
|
|
50
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
51
|
+
*
|
|
52
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
53
|
+
static POST(
|
|
54
|
+
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
55
|
+
equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
56
|
+
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
57
|
+
return EQ.checkAlgorithm(value, equivalent, invert);
|
|
58
|
+
}, dbc, path);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
62
|
+
* by the tagged field.
|
|
63
|
+
*
|
|
64
|
+
* @param equivalent See {@link EQ.checkAlgorithm }.
|
|
65
|
+
* @param path See {@link DBC.decInvariant }.
|
|
66
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
67
|
+
*
|
|
68
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
69
|
+
static INVARIANT(
|
|
70
|
+
// biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
|
|
71
|
+
equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
72
|
+
return DBC.decInvariant([new EQ(equivalent, invert)], path, dbc);
|
|
73
|
+
}
|
|
74
|
+
// #endregion Condition checking.
|
|
75
|
+
// #region Referenced Condition checking.
|
|
76
|
+
//
|
|
77
|
+
// For usage in dynamic scenarios (like with AE-DBC).
|
|
78
|
+
//
|
|
79
|
+
/**
|
|
80
|
+
* Invokes the {@link EQ.checkAlgorithm } passing the value **toCheck**, {@link EQ.equivalent } and {@link EQ.invert }.
|
|
81
|
+
*
|
|
82
|
+
* @param toCheck See {@link EQ.checkAlgorithm }.
|
|
83
|
+
*
|
|
84
|
+
* @returns See {@link EQ.checkAlgorithm}. */
|
|
85
|
+
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
86
|
+
check(toCheck) {
|
|
87
|
+
return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
|
|
91
|
+
*
|
|
92
|
+
* @param equivalent See {@link EQ.check }. */
|
|
93
|
+
constructor(
|
|
94
|
+
// biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
|
|
95
|
+
equivalent, invert = false) {
|
|
96
|
+
super();
|
|
97
|
+
this.equivalent = equivalent;
|
|
98
|
+
this.invert = invert;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/dist/DBC/INSTANCE.js
CHANGED
|
@@ -1,113 +1,93 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } defining that the an {@link object }s gotta be an instance of a certain {@link INSTANCE.reference }.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
-
export class INSTANCE extends DBC {
|
|
8
|
-
/**
|
|
9
|
-
* Checks if the value **toCheck** is
|
|
10
|
-
*
|
|
11
|
-
* @param toCheck The value that has to
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @returns TRUE if the value **toCheck** is
|
|
16
|
-
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
17
|
-
static checkAlgorithm(toCheck, reference) {
|
|
18
|
-
if (!(toCheck instanceof reference)) {
|
|
19
|
-
return `Value has to be an instance of "${reference}" but is of type "${typeof toCheck}"`;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A parameter-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
25
|
-
* by the tagged parameter.
|
|
26
|
-
*
|
|
27
|
-
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
28
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
29
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
30
|
-
*
|
|
31
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
32
|
-
static PRE(
|
|
33
|
-
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
34
|
-
reference, path = undefined, dbc = "WaXCode.DBC") {
|
|
35
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
36
|
-
return INSTANCE.checkAlgorithm(value, reference);
|
|
37
|
-
}, dbc, path);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A method-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
41
|
-
* by the tagged method's returnvalue.
|
|
42
|
-
*
|
|
43
|
-
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
44
|
-
* @param path See {@link DBC.Postcondition }.
|
|
45
|
-
* @param dbc See {@link DBC.decPostcondition }.
|
|
46
|
-
*
|
|
47
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
48
|
-
static POST(
|
|
49
|
-
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
50
|
-
reference, path = undefined, dbc = "WaXCode.DBC") {
|
|
51
|
-
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
52
|
-
return INSTANCE.checkAlgorithm(value, reference);
|
|
53
|
-
}, dbc, path);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* A field-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
57
|
-
* by the tagged method's returnvalue.
|
|
58
|
-
*
|
|
59
|
-
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
60
|
-
* @param path See {@link DBC.decInvariant }.
|
|
61
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
62
|
-
*
|
|
63
|
-
* @returns See {@link DBC.decInvariant }. */
|
|
64
|
-
static INVARIANT(
|
|
65
|
-
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
66
|
-
reference, path = undefined, dbc = "WaXCode.DBC") {
|
|
67
|
-
return DBC.decInvariant([new INSTANCE(reference)], path, dbc);
|
|
68
|
-
}
|
|
69
|
-
// #endregion Condition checking.
|
|
70
|
-
// #region Referenced Condition checking.
|
|
71
|
-
//
|
|
72
|
-
// For usage in dynamic scenarios (like with AE-DBC).
|
|
73
|
-
//
|
|
74
|
-
/**
|
|
75
|
-
* Invokes the {@link INSTANCE.checkAlgorithm } passing the value **toCheck** and the {@link INSTANCE.reference } .
|
|
76
|
-
*
|
|
77
|
-
* @param toCheck See {@link INSTANCE.checkAlgorithm }.
|
|
78
|
-
*
|
|
79
|
-
* @returns See {@link INSTANCE.checkAlgorithm}. */
|
|
80
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
81
|
-
check(toCheck) {
|
|
82
|
-
return INSTANCE.checkAlgorithm(toCheck, this.reference);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @param
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
|
|
95
|
-
static tsCheck(toCheck, reference, id = undefined, hint = undefined) {
|
|
96
|
-
const result = INSTANCE.checkAlgorithm(toCheck, reference);
|
|
97
|
-
if (result === true) {
|
|
98
|
-
return toCheck;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result} ${hint ? `< ${hint} >` : ""}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
|
|
106
|
-
*
|
|
107
|
-
* @param reference See {@link INSTANCE.check }. */
|
|
108
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
109
|
-
constructor(reference) {
|
|
110
|
-
super();
|
|
111
|
-
this.reference = reference;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that the an {@link object }s gotta be an instance of a certain {@link INSTANCE.reference }.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
+
export class INSTANCE extends DBC {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
|
|
10
|
+
*
|
|
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.
|
|
14
|
+
*
|
|
15
|
+
* @returns TRUE if the value **toCheck** is of the specified **type**, otherwise FALSE. */
|
|
16
|
+
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
17
|
+
static checkAlgorithm(toCheck, reference) {
|
|
18
|
+
if (!(toCheck instanceof reference)) {
|
|
19
|
+
return `Value has to be an instance of "${reference}" but is of type "${typeof toCheck}"`;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A parameter-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
25
|
+
* by the tagged parameter.
|
|
26
|
+
*
|
|
27
|
+
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
28
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
29
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
30
|
+
*
|
|
31
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
32
|
+
static PRE(
|
|
33
|
+
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
34
|
+
reference, path = undefined, dbc = "WaXCode.DBC") {
|
|
35
|
+
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
36
|
+
return INSTANCE.checkAlgorithm(value, reference);
|
|
37
|
+
}, dbc, path);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A method-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
41
|
+
* by the tagged method's returnvalue.
|
|
42
|
+
*
|
|
43
|
+
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
44
|
+
* @param path See {@link DBC.Postcondition }.
|
|
45
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
46
|
+
*
|
|
47
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
48
|
+
static POST(
|
|
49
|
+
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
50
|
+
reference, path = undefined, dbc = "WaXCode.DBC") {
|
|
51
|
+
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
52
|
+
return INSTANCE.checkAlgorithm(value, reference);
|
|
53
|
+
}, dbc, path);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A field-decorator factory using the {@link INSTANCE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
57
|
+
* by the tagged method's returnvalue.
|
|
58
|
+
*
|
|
59
|
+
* @param reference See {@link INSTANCE.checkAlgorithm }.
|
|
60
|
+
* @param path See {@link DBC.decInvariant }.
|
|
61
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
62
|
+
*
|
|
63
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
64
|
+
static INVARIANT(
|
|
65
|
+
// biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
|
|
66
|
+
reference, path = undefined, dbc = "WaXCode.DBC") {
|
|
67
|
+
return DBC.decInvariant([new INSTANCE(reference)], path, dbc);
|
|
68
|
+
}
|
|
69
|
+
// #endregion Condition checking.
|
|
70
|
+
// #region Referenced Condition checking.
|
|
71
|
+
//
|
|
72
|
+
// For usage in dynamic scenarios (like with AE-DBC).
|
|
73
|
+
//
|
|
74
|
+
/**
|
|
75
|
+
* Invokes the {@link INSTANCE.checkAlgorithm } passing the value **toCheck** and the {@link INSTANCE.reference } .
|
|
76
|
+
*
|
|
77
|
+
* @param toCheck See {@link INSTANCE.checkAlgorithm }.
|
|
78
|
+
*
|
|
79
|
+
* @returns See {@link INSTANCE.checkAlgorithm}. */
|
|
80
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
81
|
+
check(toCheck) {
|
|
82
|
+
return INSTANCE.checkAlgorithm(toCheck, this.reference);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
|
|
86
|
+
*
|
|
87
|
+
* @param reference See {@link INSTANCE.check }. */
|
|
88
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
89
|
+
constructor(reference) {
|
|
90
|
+
super();
|
|
91
|
+
this.reference = reference;
|
|
92
|
+
}
|
|
93
|
+
}
|