xdbc 1.0.207 → 1.0.209
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/Assessment.html +350 -0
- package/Assessment.md +507 -51
- package/CHANGELOG.md +55 -0
- package/CONTRIBUTING.md +129 -17
- package/README.md +373 -71
- package/SECURITY.md +60 -18
- package/SUPPORT.md +65 -0
- package/__tests__/DBC/DEFINED.test.ts +53 -0
- package/__tests__/DBC/Decorators.test.ts +365 -0
- package/__tests__/DBC/GREATER.test.ts +8 -6
- package/__tests__/DBC/HasAttribute.test.ts +56 -0
- package/__tests__/DBC/IF.test.ts +52 -0
- package/__tests__/DBC/JSON.Parse.test.ts +1 -1
- package/__tests__/DBC/OR.test.ts +1 -1
- package/__tests__/DBC/REGEX.test.ts +1 -1
- package/__tests__/DBC/TYPE.test.ts +1 -1
- package/__tests__/DBC/UNDEFINED.test.ts +45 -0
- package/__tests__/DBC/ZOD.test.ts +54 -0
- package/jest.config.js +21 -0
- package/package.json +4 -5
- package/src/DBC/AE.ts +10 -6
- package/src/DBC/COMPARISON/GREATER.ts +11 -7
- package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +14 -10
- package/src/DBC/COMPARISON/LESS.ts +14 -10
- package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +14 -10
- package/src/DBC/COMPARISON.ts +20 -43
- package/src/DBC/DEFINED.ts +4 -23
- package/src/DBC/EQ/DIFFERENT.ts +21 -56
- package/src/DBC/EQ.ts +7 -26
- package/src/DBC/HasAttribute.ts +9 -26
- package/src/DBC/IF.ts +8 -27
- package/src/DBC/INSTANCE.ts +5 -22
- package/src/DBC/JSON.OP.ts +4 -34
- package/src/DBC/JSON.Parse.ts +5 -25
- package/src/DBC/OR.ts +5 -14
- package/src/DBC/REGEX.ts +41 -40
- package/src/DBC/TYPE.ts +6 -25
- package/src/DBC/UNDEFINED.ts +3 -22
- package/src/DBC/ZOD.ts +10 -27
- package/src/DBC.ts +223 -55
- package/tsconfig.json +7 -4
- package/tsconfig.test.json +12 -0
- 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 +0 -4609
- package/dist/DBC/AE.js +0 -173
- package/dist/DBC/COMPARISON/GREATER.js +0 -21
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +0 -21
- package/dist/DBC/COMPARISON/LESS.js +0 -21
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +0 -21
- package/dist/DBC/COMPARISON.js +0 -99
- package/dist/DBC/DEFINED.js +0 -99
- package/dist/DBC/EQ/DIFFERENT.js +0 -21
- package/dist/DBC/EQ.js +0 -100
- package/dist/DBC/GREATER.js +0 -99
- package/dist/DBC/HasAttribute.js +0 -108
- package/dist/DBC/IF.js +0 -99
- package/dist/DBC/INSTANCE.js +0 -93
- package/dist/DBC/JSON.OP.js +0 -133
- package/dist/DBC/JSON.Parse.js +0 -114
- package/dist/DBC/OR.js +0 -113
- package/dist/DBC/REGEX.js +0 -110
- package/dist/DBC/TYPE.js +0 -87
- package/dist/DBC/ZOD.js +0 -114
- package/dist/DBC.js +0 -336
- package/dist/Demo.js +0 -290
- package/dist/Test.html +0 -18
- package/dist/bundle.js +0 -2064
- package/dist/index.html +0 -18
- package/jest.config.ts +0 -20
- package/xpackage-lock.json +0 -122
package/dist/DBC/GREATER.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
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 GREATER 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(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 GREATER.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
34
|
-
* by the tagged parameter.
|
|
35
|
-
*
|
|
36
|
-
* @param equivalent See {@link GREATER.checkAlgorithm }.
|
|
37
|
-
* @param equalityPermitted See {@link GREATER.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 GREATER.checkAlgorithm(value, equivalent, equalityPermitted, invert);
|
|
45
|
-
}, dbc, path);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A method-decorator factory using the {@link GREATER.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
49
|
-
* by the tagged method's returnvalue.
|
|
50
|
-
*
|
|
51
|
-
* @param equivalent See {@link GREATER.checkAlgorithm }.
|
|
52
|
-
* @param equalityPermitted See {@link GREATER.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 GREATER.checkAlgorithm(value, equalityPermitted, equivalent, invert);
|
|
60
|
-
}, dbc, path);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A field-decorator factory using the {@link GREATER.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
64
|
-
* by the tagged field.
|
|
65
|
-
*
|
|
66
|
-
* @param equivalent See {@link GREATER.checkAlgorithm }.
|
|
67
|
-
* @param equalityPermitted See {@link GREATER.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 GREATER(equivalent, equalityPermitted, invert)], path, dbc);
|
|
74
|
-
}
|
|
75
|
-
// #endregion Condition checking.
|
|
76
|
-
// #region Referenced Condition checking.
|
|
77
|
-
// #region Dynamic usage.
|
|
78
|
-
/**
|
|
79
|
-
* Invokes the {@link GREATER.checkAlgorithm } passing the value **toCheck**, {@link GREATER.equivalent } and {@link GREATER.invert }.
|
|
80
|
-
*
|
|
81
|
-
* @param toCheck See {@link GREATER.checkAlgorithm }.
|
|
82
|
-
*
|
|
83
|
-
* @returns See {@link GREATER.checkAlgorithm}. */
|
|
84
|
-
check(toCheck) {
|
|
85
|
-
return GREATER.checkAlgorithm(toCheck, this.equivalent, this.equalityPermitted, this.invert);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates this {@link GREATER } by setting the protected property {@link GREATER.equivalent }, {@link GREATER.equalityPermitted } and {@link GREATER.invert } used by {@link GREATER.check }.
|
|
89
|
-
*
|
|
90
|
-
* @param equivalent See {@link GREATER.check }.
|
|
91
|
-
* @param equalityPermitted See {@link GREATER.check }.
|
|
92
|
-
* @param invert See {@link GREATER.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/HasAttribute.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } defining that a {@link HTMLElement } gotta have a certain attribute set.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
-
export class HasAttribute extends DBC {
|
|
8
|
-
// #region Condition checking.
|
|
9
|
-
/**
|
|
10
|
-
* Checks if the {@link HTMLElement } **toCheck** has the attribute **toCheckFor**.
|
|
11
|
-
*
|
|
12
|
-
* @param toCheckFor name of the attribute to check for whether it is set or not.
|
|
13
|
-
*
|
|
14
|
-
* @returns TRUE if the {@link HTMLElement } **toCheck** has set the attribute **toCheckFor**,
|
|
15
|
-
* otherwise a proper errormessage. */
|
|
16
|
-
static checkAlgorithm(
|
|
17
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
18
|
-
toCheck, toCheckFor, invert) {
|
|
19
|
-
if (!(toCheck instanceof HTMLElement)) {
|
|
20
|
-
return `The object to check for whether it has the attribute "${toCheckFor}" is not a HTMLElement. It is of type "${typeof toCheck}".`;
|
|
21
|
-
}
|
|
22
|
-
if (!invert && !toCheck.hasAttribute(toCheckFor)) {
|
|
23
|
-
return `Required Attribute "${toCheckFor}" is not set.`;
|
|
24
|
-
}
|
|
25
|
-
if (invert && toCheck.hasAttribute(toCheckFor)) {
|
|
26
|
-
return `Forbidden Attribute "${toCheckFor}" is set.`;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* A parameter-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
32
|
-
* by the tagged parameter.
|
|
33
|
-
*
|
|
34
|
-
* @param toCheckFor See {@link HasAttribute.checkAlgorithm }.
|
|
35
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
36
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
37
|
-
*
|
|
38
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
39
|
-
static PRE(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
40
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
41
|
-
return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
|
|
42
|
-
}, dbc, path);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* A method-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
46
|
-
* fulfilled by the tagged method's returnvalue.
|
|
47
|
-
*
|
|
48
|
-
* @param toCheckFor See {@link HasAttribute.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(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
54
|
-
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
55
|
-
return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
|
|
56
|
-
}, dbc, path);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
60
|
-
* fulfilled by the tagged field.
|
|
61
|
-
*
|
|
62
|
-
* @param toCheckFor See {@link hasAttribute.checkAlgorithm }.
|
|
63
|
-
* @param path See {@link DBC.decInvariant }.
|
|
64
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
65
|
-
*
|
|
66
|
-
* @returns See {@link DBC.decInvariant }. */
|
|
67
|
-
static INVARIANT(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
68
|
-
return DBC.decInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
72
|
-
* fulfilled by the tagged field's class instance.
|
|
73
|
-
*
|
|
74
|
-
* @param toCheckFor See {@link hasAttribute.checkAlgorithm }.
|
|
75
|
-
* @param path See {@link DBC.decInvariant }.
|
|
76
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
77
|
-
*
|
|
78
|
-
* @returns See {@link DBC.decInvariant }. */
|
|
79
|
-
static cINVARIANT(toCheckFor, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
80
|
-
return DBC.decClassInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
|
|
81
|
-
}
|
|
82
|
-
// #endregion Condition checking.
|
|
83
|
-
// #region Referenced Condition checking.
|
|
84
|
-
//
|
|
85
|
-
// For usage in dynamic scenarios (like with AE-DBC).
|
|
86
|
-
//
|
|
87
|
-
/**
|
|
88
|
-
* Invokes the {@link hasAttribute.checkAlgorithm } passing the value **toCheck**, {@link hasAttribute.equivalent } and
|
|
89
|
-
* {@link hasAttribute.invert }.
|
|
90
|
-
*
|
|
91
|
-
* @param toCheck See {@link EQ.checkAlgorithm }.
|
|
92
|
-
*
|
|
93
|
-
* @returns See {@link EQ.checkAlgorithm}. */
|
|
94
|
-
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
95
|
-
check(toCheck) {
|
|
96
|
-
return HasAttribute.checkAlgorithm(toCheck, this.toCheckFor, this.invert);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Creates this {@link DBC } by setting the protected property {@link hasAttribute.equivalent } used by
|
|
100
|
-
* {@link hasAttribute.check }.
|
|
101
|
-
*
|
|
102
|
-
* @param toCheckFor See {@link hasAttribute.check }. */
|
|
103
|
-
constructor(toCheckFor, invert = false) {
|
|
104
|
-
super();
|
|
105
|
-
this.toCheckFor = toCheckFor;
|
|
106
|
-
this.invert = invert;
|
|
107
|
-
}
|
|
108
|
-
}
|
package/dist/DBC/IF.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } defining that an {@link object } has also to comply to a certain {@link DBC } if it complies to
|
|
4
|
-
* another specified one.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
8
|
-
export class IF extends DBC {
|
|
9
|
-
// #region Condition checking.
|
|
10
|
-
/**
|
|
11
|
-
* Checks if the value **toCheck** complies to the specified **condition** and if so does also comply to the one **inCase**.
|
|
12
|
-
*
|
|
13
|
-
* @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
|
|
14
|
-
* @param condition The contract **toCheck** has to comply to in order to also have to comply to the one **inCase**.
|
|
15
|
-
* @param inCase The contract **toCheck** has to also comply to if it complies to **condition**.
|
|
16
|
-
*
|
|
17
|
-
* @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
|
|
18
|
-
static checkAlgorithm(
|
|
19
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
20
|
-
toCheck, condition, inCase, invert) {
|
|
21
|
-
if (!invert && condition.check(toCheck) && !inCase.check(toCheck)) {
|
|
22
|
-
return `In case that the value complies to "${condition}" it also has to comply to "${inCase}"`;
|
|
23
|
-
}
|
|
24
|
-
if (!invert && !condition.check(toCheck) && !inCase.check(toCheck)) {
|
|
25
|
-
return `In case that the value does not comply to "${condition}" it has to comply to "${inCase}"`;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
31
|
-
* by the tagged parameter.
|
|
32
|
-
*
|
|
33
|
-
* @param condition See {@link IF.checkAlgorithm }.
|
|
34
|
-
* @param inCase See {@link IF.checkAlgorithm }.
|
|
35
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
36
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
37
|
-
*
|
|
38
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
39
|
-
static PRE(condition, inCase, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
40
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
41
|
-
return IF.checkAlgorithm(value, condition, inCase, invert);
|
|
42
|
-
}, dbc, path);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
46
|
-
* by the tagged method's returnvalue.
|
|
47
|
-
*
|
|
48
|
-
* @param condition See {@link IF.checkAlgorithm }.
|
|
49
|
-
* @param inCase See {@link IF.checkAlgorithm }.
|
|
50
|
-
* @param path See {@link DBC.Postcondition }.
|
|
51
|
-
* @param dbc See {@link DBC.decPostcondition }.
|
|
52
|
-
*
|
|
53
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
54
|
-
static POST(condition, inCase, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
55
|
-
return DBC.decPostcondition((value, target, propertyKey) => {
|
|
56
|
-
return IF.checkAlgorithm(value, condition, inCase, invert);
|
|
57
|
-
}, dbc, path);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
61
|
-
* by the tagged field.
|
|
62
|
-
*
|
|
63
|
-
* @param condition See {@link IF.checkAlgorithm }.
|
|
64
|
-
* @param inCase See {@link IF.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(condition, inCase, invert = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
70
|
-
return DBC.decInvariant([new IF(condition, inCase, invert)], path, dbc);
|
|
71
|
-
}
|
|
72
|
-
// #endregion Condition checking.
|
|
73
|
-
// #region Referenced Condition checking.
|
|
74
|
-
//
|
|
75
|
-
// For usage in dynamic scenarios (like with AE-DBC).
|
|
76
|
-
//
|
|
77
|
-
/**
|
|
78
|
-
* Invokes the {@link IF.checkAlgorithm } passing the value **toCheck**, {@link IF.equivalent } and {@link IF.invert }.
|
|
79
|
-
*
|
|
80
|
-
* @param toCheck See {@link IF.checkAlgorithm }.
|
|
81
|
-
*
|
|
82
|
-
* @returns See {@link IF.checkAlgorithm}. */
|
|
83
|
-
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
84
|
-
check(toCheck) {
|
|
85
|
-
return IF.checkAlgorithm(toCheck, this.condition, this.inCase, this.invert);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates this {@link IF } by setting the protected property {@link IF.equivalent } used by {@link IF.check }.
|
|
89
|
-
*
|
|
90
|
-
* @param equivalent See {@link IF.check }. */
|
|
91
|
-
constructor(
|
|
92
|
-
// biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
|
|
93
|
-
condition, inCase, invert = false) {
|
|
94
|
-
super();
|
|
95
|
-
this.condition = condition;
|
|
96
|
-
this.inCase = inCase;
|
|
97
|
-
this.invert = invert;
|
|
98
|
-
}
|
|
99
|
-
}
|
package/dist/DBC/INSTANCE.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/DBC/JSON.OP.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } demanding that an {@link object } has specific properties of specific types.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
-
export class JSON_OP extends DBC {
|
|
8
|
-
// #region Condition checking.
|
|
9
|
-
/**
|
|
10
|
-
* Checks if the object **toCheck** has the **necessaryProperties** of necessary type.
|
|
11
|
-
*
|
|
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
|
|
14
|
-
* check needs to have.
|
|
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
|
-
* will be checked.
|
|
18
|
-
*
|
|
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
|
-
static checkAlgorithm(
|
|
21
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
22
|
-
toCheck, necessaryProperties, checkElements) {
|
|
23
|
-
if (toCheck === undefined || null) {
|
|
24
|
-
return `[ UNDEFINED or NULL received instead of object with following properties: ${JSON.stringify(necessaryProperties)} ]`;
|
|
25
|
-
}
|
|
26
|
-
for (const property of necessaryProperties)
|
|
27
|
-
if (checkElements && typeof toCheck[Symbol.iterator] === "function") {
|
|
28
|
-
for (const element of toCheck) {
|
|
29
|
-
if (
|
|
30
|
-
// biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
|
|
31
|
-
!element.hasOwnProperty(property.name) ||
|
|
32
|
-
// biome-ignore lint/suspicious/useValidTypeof: <explanation>
|
|
33
|
-
typeof element[property.name] !== property.type) {
|
|
34
|
-
return `[ Object "${JSON.stringify(element)}" in Array "${JSON.stringify(toCheck)}" does not contain the necessary property "${property.name}" of type "${property.type}"]`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
if (
|
|
40
|
-
// biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
|
|
41
|
-
!toCheck.hasOwnProperty(property.name) ||
|
|
42
|
-
// biome-ignore lint/suspicious/useValidTypeof: <explanation>
|
|
43
|
-
typeof toCheck[property.name] !== property.type) {
|
|
44
|
-
return `[ Object does not contain the necessary property "${property.name}" of type "${property.type}"]`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* A parameter-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
51
|
-
* by the tagged parameter.
|
|
52
|
-
*
|
|
53
|
-
* @param expression See {@link JSON.checkAlgorithm }.
|
|
54
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
55
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
56
|
-
*
|
|
57
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
58
|
-
static PRE(necessaryProperties, checkElements = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
59
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
60
|
-
return JSON_OP.checkAlgorithm(value, necessaryProperties, checkElements);
|
|
61
|
-
}, dbc, path);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A method-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
65
|
-
* by the tagged method's returnvalue.
|
|
66
|
-
*
|
|
67
|
-
* @param expression See {@link JSON.checkAlgorithm }.
|
|
68
|
-
* @param path See {@link DBC.Postcondition }.
|
|
69
|
-
* @param dbc See {@link DBC.decPostcondition }.
|
|
70
|
-
*
|
|
71
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
72
|
-
static POST(necessaryProperties, checkElements = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
73
|
-
return DBC.decPostcondition(
|
|
74
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
75
|
-
(value, target, propertyKey) => {
|
|
76
|
-
return JSON_OP.checkAlgorithm(value, necessaryProperties, checkElements);
|
|
77
|
-
}, dbc, path);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* A field-decorator factory using the {@link JSON_OP.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
81
|
-
* by the tagged field.
|
|
82
|
-
*
|
|
83
|
-
* @param expression See {@link JSON.checkAlgorithm }.
|
|
84
|
-
* @param path See {@link DBC.decInvariant }.
|
|
85
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
86
|
-
*
|
|
87
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
88
|
-
static INVARIANT(necessaryProperties, checkElements = false, path = undefined, dbc = "WaXCode.DBC") {
|
|
89
|
-
return DBC.decInvariant([new JSON_OP(necessaryProperties, checkElements)], path, dbc);
|
|
90
|
-
}
|
|
91
|
-
// #endregion Condition checking.
|
|
92
|
-
// #region Referenced Condition checking.
|
|
93
|
-
//
|
|
94
|
-
// For usage in dynamic scenarios (like with AE-DBC).
|
|
95
|
-
//
|
|
96
|
-
/**
|
|
97
|
-
* Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
|
|
98
|
-
*
|
|
99
|
-
* @param toCheck See {@link JSON_OP.checkAlgorithm }.
|
|
100
|
-
*
|
|
101
|
-
* @returns See {@link JSON_OP.checkAlgorithm}. */
|
|
102
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
103
|
-
check(toCheck) {
|
|
104
|
-
return JSON_OP.checkAlgorithm(toCheck, this.necessaryProperties, this.checkElements);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Creates this {@link JSON_OP } by setting the protected property {@link JSON_OP.necessaryProperties } and {@link checkElements } used by {@link JSON_OP.check }.
|
|
108
|
-
*
|
|
109
|
-
* @param necessaryProperties See {@link JSON_OP.check }.
|
|
110
|
-
* @param checkElements See {@link JSON_OP.check }. */
|
|
111
|
-
constructor(necessaryProperties, checkElements = false) {
|
|
112
|
-
super();
|
|
113
|
-
this.necessaryProperties = necessaryProperties;
|
|
114
|
-
this.checkElements = checkElements;
|
|
115
|
-
}
|
|
116
|
-
// #endregion Referenced Condition checking.
|
|
117
|
-
// #region In-Method checking.
|
|
118
|
-
/**
|
|
119
|
-
* Invokes the {@link JSON_OP.checkAlgorithm } passing the value **toCheck**, {@link JSON_OP.necessaryProperties } and {@link JSON_OP.checkElements }.
|
|
120
|
-
*
|
|
121
|
-
* @param toCheck See {@link JSON_OP.checkAlgorithm} }.
|
|
122
|
-
* @param necessaryProperties See {@link JSON_OP.checkAlgorithm} }.
|
|
123
|
-
* @param checkElements See {@link JSON_OP.checkAlgorithm} }.
|
|
124
|
-
*/
|
|
125
|
-
static check(
|
|
126
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
127
|
-
toCheck, necessaryProperties, checkElements = false) {
|
|
128
|
-
const checkResult = JSON_OP.checkAlgorithm(toCheck, necessaryProperties, checkElements);
|
|
129
|
-
if (typeof checkResult === "string") {
|
|
130
|
-
throw new DBC.Infringement(checkResult);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
package/dist/DBC/JSON.Parse.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { DBC } from "../DBC";
|
|
2
|
-
/**
|
|
3
|
-
* A {@link DBC } demanding that a {@link string } is {@link JSON.parse}able.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
-
export class JSON_Parse extends DBC {
|
|
8
|
-
// #region Condition checking.
|
|
9
|
-
/**
|
|
10
|
-
* Tries to {@link JSON.parse } the {@link string } **toCheck** invoking the **receptor** with the result, if so.
|
|
11
|
-
*
|
|
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 } **toCheck**.
|
|
14
|
-
* check needs to have.
|
|
15
|
-
*
|
|
16
|
-
* @returns TRUE if the value **toCheck** is a valid JSON, otherwise a {@link string } to report the infringement. */
|
|
17
|
-
static checkAlgorithm(toCheck, receptor) {
|
|
18
|
-
// biome-ignore lint/suspicious/noExplicitAny: JSON.parse returns any.
|
|
19
|
-
let parsed;
|
|
20
|
-
try {
|
|
21
|
-
parsed = JSON.parse(toCheck);
|
|
22
|
-
}
|
|
23
|
-
catch (X) {
|
|
24
|
-
return `[ Following string is not a valid JSON: ${toCheck}]`;
|
|
25
|
-
}
|
|
26
|
-
if (receptor) {
|
|
27
|
-
receptor(parsed);
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* A parameter-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
33
|
-
* by the tagged parameter.
|
|
34
|
-
*
|
|
35
|
-
* @param receptor See {@link JSON.checkAlgorithm }.
|
|
36
|
-
* @param path See {@link DBC.decPrecondition }.
|
|
37
|
-
* @param dbc See {@link DBC.decPrecondition }.
|
|
38
|
-
*
|
|
39
|
-
* @returns See {@link DBC.decPrecondition }. */
|
|
40
|
-
static PRE(receptor, path = undefined, dbc = "WaXCode.DBC") {
|
|
41
|
-
return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
|
|
42
|
-
return JSON_Parse.checkAlgorithm(value, receptor);
|
|
43
|
-
}, dbc, path);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
47
|
-
* by the tagged method's returnvalue.
|
|
48
|
-
*
|
|
49
|
-
* @param expression See {@link JSON.checkAlgorithm }.
|
|
50
|
-
* @param path See {@link DBC.Postcondition }.
|
|
51
|
-
* @param dbc See {@link DBC.decPostcondition }.
|
|
52
|
-
*
|
|
53
|
-
* @returns See {@link DBC.decPostcondition }. */
|
|
54
|
-
static POST(receptor, path = undefined, dbc = "WaXCode.DBC") {
|
|
55
|
-
return DBC.decPostcondition(
|
|
56
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
57
|
-
(value, target, propertyKey) => {
|
|
58
|
-
return JSON_Parse.checkAlgorithm(value, receptor);
|
|
59
|
-
}, dbc, path);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
63
|
-
* by the tagged field.
|
|
64
|
-
*
|
|
65
|
-
* @param expression See {@link JSON.checkAlgorithm }.
|
|
66
|
-
* @param path See {@link DBC.decInvariant }.
|
|
67
|
-
* @param dbc See {@link DBC.decInvariant }.
|
|
68
|
-
*
|
|
69
|
-
* @returns See {@link DBC.decInvariant }. */
|
|
70
|
-
static INVARIANT(receptor, path = undefined, dbc = "WaXCode.DBC") {
|
|
71
|
-
return DBC.decInvariant([new JSON_Parse(receptor)], path, dbc);
|
|
72
|
-
}
|
|
73
|
-
// #endregion Condition checking.
|
|
74
|
-
// #region Referenced Condition checking.
|
|
75
|
-
//
|
|
76
|
-
// For usage in dynamic scenarios (like with AE-DBC).
|
|
77
|
-
//
|
|
78
|
-
/**
|
|
79
|
-
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck** and {@link JSON_Parse.receptor }.
|
|
80
|
-
*
|
|
81
|
-
* @param toCheck See {@link JSON_Parse.checkAlgorithm }.
|
|
82
|
-
*
|
|
83
|
-
* @returns See {@link JSON_Parse.checkAlgorithm}. */
|
|
84
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
85
|
-
check(toCheck) {
|
|
86
|
-
return JSON_Parse.checkAlgorithm(toCheck, this.receptor);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
|
|
90
|
-
*
|
|
91
|
-
* @param necessaryProperties See {@link JSON_Parse.check }.
|
|
92
|
-
* @param checkElements See {@link JSON_Parse.check }. */
|
|
93
|
-
constructor(receptor = undefined) {
|
|
94
|
-
super();
|
|
95
|
-
this.receptor = receptor;
|
|
96
|
-
}
|
|
97
|
-
// #endregion Referenced Condition checking.
|
|
98
|
-
// #region In-Method checking.
|
|
99
|
-
/**
|
|
100
|
-
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck**, {@link JSON_Parse.necessaryProperties } and {@link JSON_Parse.checkElements }.
|
|
101
|
-
*
|
|
102
|
-
* @param toCheck See {@link JSON_Parse.checkAlgorithm} }.
|
|
103
|
-
* @param necessaryProperties See {@link JSON_Parse.checkAlgorithm} }.
|
|
104
|
-
* @param checkElements See {@link JSON_Parse.checkAlgorithm} }.
|
|
105
|
-
*/
|
|
106
|
-
static check(
|
|
107
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
108
|
-
toCheck, receptor) {
|
|
109
|
-
const checkResult = JSON_Parse.checkAlgorithm(toCheck, receptor);
|
|
110
|
-
if (typeof checkResult === "string") {
|
|
111
|
-
throw new DBC.Infringement(checkResult);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|