xdbc 1.0.211 → 1.0.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +8 -0
- package/.github/workflows/ci.yml +51 -0
- package/.vscode/tasks.json +23 -23
- package/CODE_OF_CONDUCT.md +1 -1
- package/README.md +1 -0
- package/__tests__/DBC/AE.test.ts +1 -1
- package/__tests__/DBC/DEFINED.test.ts +49 -49
- package/__tests__/DBC/Decorators.test.ts +334 -332
- package/__tests__/DBC/HasAttribute.test.ts +56 -52
- package/__tests__/DBC/IF.test.ts +57 -57
- package/__tests__/DBC/OR.test.ts +1 -1
- package/__tests__/DBC/UNDEFINED.test.ts +41 -41
- package/__tests__/DBC/ZOD.test.ts +50 -50
- package/biome.json +40 -33
- package/dist/DBC/AE.d.ts +117 -0
- package/dist/DBC/COMPARISON/GREATER.d.ts +13 -0
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.d.ts +13 -0
- package/dist/DBC/COMPARISON/LESS.d.ts +13 -0
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.d.ts +13 -0
- package/dist/DBC/COMPARISON.d.ts +70 -0
- package/dist/DBC/DEFINED.d.ts +62 -0
- package/dist/DBC/EQ/DIFFERENT.d.ts +26 -0
- package/dist/DBC/EQ.d.ts +70 -0
- package/dist/DBC/HasAttribute.d.ts +72 -0
- package/dist/DBC/IF.d.ts +90 -0
- package/dist/DBC/INSTANCE.d.ts +84 -0
- package/dist/DBC/JSON.OP.d.ts +94 -0
- package/dist/DBC/JSON.Parse.d.ts +69 -0
- package/dist/DBC/OR.d.ts +104 -0
- package/dist/DBC/REGEX.d.ts +96 -0
- package/dist/DBC/TYPE.d.ts +75 -0
- package/dist/DBC/UNDEFINED.d.ts +62 -0
- package/dist/DBC/ZOD.d.ts +72 -0
- package/dist/DBC.d.ts +244 -0
- package/dist/Demo.d.ts +20 -0
- package/dist/bundle.js +2297 -0
- package/docs/assets/highlight.css +22 -22
- package/docs/assets/icons.js +17 -17
- package/docs/assets/main.js +60 -60
- package/docs/assets/style.css +1640 -1640
- package/docs/classes/DBC.DBC.html +98 -98
- package/docs/classes/DBC_AE.AE.html +160 -160
- package/docs/classes/DBC_EQ.EQ.html +131 -131
- package/docs/classes/DBC_GREATER.GREATER.html +139 -139
- package/docs/classes/DBC_INSTANCE.INSTANCE.html +130 -130
- package/docs/classes/DBC_JSON.OP.JSON_OP.html +138 -138
- package/docs/classes/DBC_JSON.Parse.JSON_Parse.html +129 -129
- package/docs/classes/DBC_OR.OR.html +137 -137
- package/docs/classes/DBC_REGEX.REGEX.html +136 -136
- package/docs/classes/DBC_TYPE.TYPE.html +130 -130
- package/docs/classes/Demo.Demo.html +14 -14
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +1 -1
- package/docs/modules/DBC.html +1 -1
- package/docs/modules/DBC_AE.html +1 -1
- package/docs/modules/DBC_EQ.html +1 -1
- package/docs/modules/DBC_GREATER.html +1 -1
- package/docs/modules/DBC_INSTANCE.html +1 -1
- package/docs/modules/DBC_JSON.OP.html +1 -1
- package/docs/modules/DBC_JSON.Parse.html +1 -1
- package/docs/modules/DBC_OR.html +1 -1
- package/docs/modules/DBC_REGEX.html +1 -1
- package/docs/modules/DBC_TYPE.html +1 -1
- package/docs/modules/Demo.html +1 -1
- package/jest.config.js +29 -18
- package/package.json +6 -2
- package/src/DBC/AE.ts +14 -9
- package/src/DBC/COMPARISON/GREATER.ts +2 -2
- package/src/DBC/COMPARISON.ts +159 -136
- package/src/DBC/DEFINED.ts +10 -10
- package/src/DBC/EQ/DIFFERENT.ts +3 -3
- package/src/DBC/EQ.ts +25 -9
- package/src/DBC/HasAttribute.ts +17 -3
- package/src/DBC/IF.ts +63 -19
- package/src/DBC/INSTANCE.ts +29 -14
- package/src/DBC/JSON.OP.ts +18 -3
- package/src/DBC/JSON.Parse.ts +21 -4
- package/src/DBC/OR.ts +12 -7
- package/src/DBC/REGEX.ts +30 -21
- package/src/DBC/TYPE.ts +15 -11
- package/src/DBC/UNDEFINED.ts +7 -10
- package/src/DBC/ZOD.ts +14 -9
- package/src/DBC.ts +165 -69
- package/src/Demo.ts +21 -18
- package/test.drawio +0 -0
- package/tsconfig.json +3 -5
- package/tsconfig.test.json +6 -11
- package/webpack.config.js +1 -1
|
@@ -1,56 +1,60 @@
|
|
|
1
1
|
import { HasAttribute } from "../../src/DBC/HasAttribute";
|
|
2
2
|
|
|
3
3
|
describe("HasAttribute", () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
4
|
+
const hasId = new HasAttribute("id");
|
|
5
|
+
|
|
6
|
+
test("Should not report infringement when attribute exists", () => {
|
|
7
|
+
const el = document.createElement("div");
|
|
8
|
+
el.setAttribute("id", "test");
|
|
9
|
+
expect(hasId.check(el)).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("Should report infringement when attribute is missing", () => {
|
|
13
|
+
const el = document.createElement("div");
|
|
14
|
+
expect(typeof hasId.check(el)).toBe("string");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("Should report infringement when value is not an HTMLElement", () => {
|
|
18
|
+
expect(typeof hasId.check("not an element")).toBe("string");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("Should report infringement when value is a plain object", () => {
|
|
22
|
+
expect(typeof hasId.check({ id: "test" })).toBe("string");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("invert", () => {
|
|
26
|
+
const noId = new HasAttribute("id", true);
|
|
27
|
+
|
|
28
|
+
test("Should not report infringement when attribute is absent", () => {
|
|
29
|
+
const el = document.createElement("div");
|
|
30
|
+
expect(noId.check(el)).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("Should report infringement when forbidden attribute exists", () => {
|
|
34
|
+
const el = document.createElement("div");
|
|
35
|
+
el.setAttribute("id", "test");
|
|
36
|
+
expect(typeof noId.check(el)).toBe("string");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("checkAlgorithm", () => {
|
|
41
|
+
test("Should return true when element has the attribute", () => {
|
|
42
|
+
const el = document.createElement("span");
|
|
43
|
+
el.setAttribute("class", "active");
|
|
44
|
+
expect(HasAttribute.checkAlgorithm(el, "class", false)).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("Should return string when element lacks the attribute", () => {
|
|
48
|
+
const el = document.createElement("span");
|
|
49
|
+
expect(typeof HasAttribute.checkAlgorithm(el, "class", false)).toBe(
|
|
50
|
+
"string",
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("Should return string for non-HTMLElement", () => {
|
|
55
|
+
expect(typeof HasAttribute.checkAlgorithm(42, "id", false)).toBe(
|
|
56
|
+
"string",
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
56
60
|
});
|
package/__tests__/DBC/IF.test.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { IF } from "../../src/DBC/IF";
|
|
2
1
|
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
+
import { IF } from "../../src/DBC/IF";
|
|
3
3
|
import { TYPE } from "../../src/DBC/TYPE";
|
|
4
4
|
|
|
5
5
|
describe("IF", () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
6
|
+
const isString = new TYPE("string");
|
|
7
|
+
const eqHello = new EQ("hello");
|
|
8
|
+
|
|
9
|
+
const ifContract = new IF(isString, eqHello);
|
|
10
|
+
|
|
11
|
+
test("Should not report infringement when condition matches and inCase is fulfilled", () => {
|
|
12
|
+
expect(ifContract.check("hello")).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("Should report infringement when condition matches but inCase is not fulfilled", () => {
|
|
16
|
+
expect(typeof ifContract.check("world")).toBe("string");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("Should not report infringement when condition does not match", () => {
|
|
20
|
+
expect(ifContract.check(42)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("invert", () => {
|
|
24
|
+
const invertedContract = new IF(isString, eqHello, true);
|
|
25
|
+
|
|
26
|
+
test("Should not report infringement when condition does not match and inCase is fulfilled", () => {
|
|
27
|
+
expect(invertedContract.check("hello")).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("Should report infringement when condition does not match and inCase is not fulfilled", () => {
|
|
31
|
+
expect(typeof invertedContract.check(42)).toBe("string");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("Should not report infringement when condition matches", () => {
|
|
35
|
+
expect(invertedContract.check("world")).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("checkAlgorithm", () => {
|
|
40
|
+
test("Should return true when condition not met", () => {
|
|
41
|
+
expect(IF.checkAlgorithm(123, isString, eqHello)).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Should return string when condition met but inCase fails", () => {
|
|
45
|
+
expect(typeof IF.checkAlgorithm("notHello", isString, eqHello)).toBe(
|
|
46
|
+
"string",
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("Should return true when both condition and inCase pass", () => {
|
|
51
|
+
expect(IF.checkAlgorithm("hello", isString, eqHello)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("Should return true when toCheck is undefined", () => {
|
|
55
|
+
expect(IF.checkAlgorithm(undefined, isString, eqHello)).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("Should return true when toCheck is null", () => {
|
|
59
|
+
expect(IF.checkAlgorithm(null, isString, eqHello)).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
62
|
});
|
package/__tests__/DBC/OR.test.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { UNDEFINED } from "../../src/DBC/UNDEFINED";
|
|
2
2
|
|
|
3
3
|
describe("UNDEFINED", () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
4
|
+
const undef = new UNDEFINED();
|
|
5
|
+
|
|
6
|
+
test("Should not report infringement with undefined", () => {
|
|
7
|
+
expect(undef.check(undefined)).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("Should report infringement with null", () => {
|
|
11
|
+
expect(typeof undef.check(null)).toBe("string");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("Should report infringement with a string value", () => {
|
|
15
|
+
expect(typeof undef.check("hello")).toBe("string");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("Should report infringement with a number value", () => {
|
|
19
|
+
expect(typeof undef.check(42)).toBe("string");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("Should report infringement with zero", () => {
|
|
23
|
+
expect(typeof undef.check(0)).toBe("string");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("Should report infringement with false", () => {
|
|
27
|
+
expect(typeof undef.check(false)).toBe("string");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("Should report infringement with an empty string", () => {
|
|
31
|
+
expect(typeof undef.check("")).toBe("string");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe("checkAlgorithm", () => {
|
|
35
|
+
test("Should return true for undefined", () => {
|
|
36
|
+
expect(UNDEFINED.checkAlgorithm(undefined)).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("Should return string for defined values", () => {
|
|
40
|
+
expect(typeof UNDEFINED.checkAlgorithm("test")).toBe("string");
|
|
41
|
+
expect(typeof UNDEFINED.checkAlgorithm(0)).toBe("string");
|
|
42
|
+
expect(typeof UNDEFINED.checkAlgorithm(null)).toBe("string");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
45
|
});
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { ZOD } from "../../src/DBC/ZOD";
|
|
2
1
|
import { z } from "zod";
|
|
2
|
+
import { ZOD } from "../../src/DBC/ZOD";
|
|
3
3
|
|
|
4
4
|
describe("ZOD", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
5
|
+
describe("string schema", () => {
|
|
6
|
+
const zodString = new ZOD(z.string());
|
|
7
|
+
|
|
8
|
+
test("Should not report infringement with a string value", () => {
|
|
9
|
+
expect(zodString.check("hello")).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("Should report infringement with a number value", () => {
|
|
13
|
+
expect(typeof zodString.check(42)).toBe("string");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe("number schema", () => {
|
|
18
|
+
const zodNumber = new ZOD(z.number());
|
|
19
|
+
|
|
20
|
+
test("Should not report infringement with a number value", () => {
|
|
21
|
+
expect(zodNumber.check(42)).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("Should report infringement with a string value", () => {
|
|
25
|
+
expect(typeof zodNumber.check("hello")).toBe("string");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("object schema", () => {
|
|
30
|
+
const zodObject = new ZOD(z.object({ name: z.string(), age: z.number() }));
|
|
31
|
+
|
|
32
|
+
test("Should not report infringement with a valid object", () => {
|
|
33
|
+
expect(zodObject.check({ name: "Alice", age: 30 })).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("Should report infringement with an invalid object", () => {
|
|
37
|
+
expect(typeof zodObject.check({ name: 123 })).toBe("string");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("Should report infringement with a non-object value", () => {
|
|
41
|
+
expect(typeof zodObject.check("not an object")).toBe("string");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("checkAlgorithm", () => {
|
|
46
|
+
test("Should return true for valid value", () => {
|
|
47
|
+
expect(ZOD.checkAlgorithm("test", z.string())).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("Should return string for invalid value", () => {
|
|
51
|
+
expect(typeof ZOD.checkAlgorithm(42, z.string())).toBe("string");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
54
|
});
|
package/biome.json
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": false,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": false
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false,
|
|
10
|
+
"ignore": ["dist/**", "node_modules/**", "docs/**", "coverage/**"]
|
|
11
|
+
},
|
|
12
|
+
"formatter": {
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"indentStyle": "tab"
|
|
15
|
+
},
|
|
16
|
+
"organizeImports": {
|
|
17
|
+
"enabled": true
|
|
18
|
+
},
|
|
19
|
+
"linter": {
|
|
20
|
+
"enabled": true,
|
|
21
|
+
"rules": {
|
|
22
|
+
"recommended": true,
|
|
23
|
+
"suspicious": {
|
|
24
|
+
"noExplicitAny": "off",
|
|
25
|
+
"useValidTypeof": "off"
|
|
26
|
+
},
|
|
27
|
+
"style": {
|
|
28
|
+
"noNonNullAssertion": "off"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"javascript": {
|
|
33
|
+
"parser": {
|
|
34
|
+
"unsafeParameterDecoratorsEnabled": true
|
|
35
|
+
},
|
|
36
|
+
"formatter": {
|
|
37
|
+
"quoteStyle": "double"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/DBC/AE.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that all elements of an {@link object }s have to fulfill
|
|
4
|
+
* a given {@link object }'s check-method (**( toCheck : any ) => boolean | string**).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
8
|
+
export declare class AE extends DBC {
|
|
9
|
+
protected conditions: Array<{
|
|
10
|
+
check: (toCheck: any) => boolean | string;
|
|
11
|
+
}> | {
|
|
12
|
+
check: (toCheck: any) => boolean | string;
|
|
13
|
+
};
|
|
14
|
+
protected index: number | undefined;
|
|
15
|
+
protected idxEnd: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Checks each element of the **value**-{@link Array < any >} against the given **condition**, if it is one. If it is not
|
|
18
|
+
* the **value** itself will be checked.
|
|
19
|
+
*
|
|
20
|
+
* @param condition The { check: (toCheck: any) => boolean | string } to check the **value** against.
|
|
21
|
+
* @param value Either **value**-{@link Array < any >}, which's elements will be checked, or the value to be
|
|
22
|
+
* checked itself.
|
|
23
|
+
* @param index If specified with **idxEnd** being undefined, this {@link Number } will be seen as the index of
|
|
24
|
+
* the value-{@link Array }'s element to check. If value isn't an {@link Array } this parameter
|
|
25
|
+
* will not have any effect.
|
|
26
|
+
* With **idxEnd** not undefined this parameter indicates the beginning of the span of elements to
|
|
27
|
+
* check within the value-{@link Array }.
|
|
28
|
+
* @param idxEnd Indicates the last element's index (including) of the span of value-{@link Array } elements to check.
|
|
29
|
+
* Setting this parameter to -1 specifies that all value-{@link Array }'s elements beginning from the
|
|
30
|
+
* specified **index** shall be checked.
|
|
31
|
+
*
|
|
32
|
+
* @returns As soon as the **condition** returns a {@link string }, instead of TRUE, the returned string. TRUE if the
|
|
33
|
+
* **condition** never returns a {@link string}. */
|
|
34
|
+
static checkAlgorithm(condition: {
|
|
35
|
+
check: (toCheck: unknown | null | undefined) => boolean | string;
|
|
36
|
+
}, value: object, index: number | undefined, idxEnd: number | undefined): boolean | string;
|
|
37
|
+
/**
|
|
38
|
+
* A parameter-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
|
|
39
|
+
* of the **realConditions** to check the tagged parameter-value against with.
|
|
40
|
+
* When specifying an **index** and the tagged parameter's **value** is an {@link Array }, the **realConditions** apply to the
|
|
41
|
+
* element at the specified **index**.
|
|
42
|
+
* If the {@link Array } is too short the currently processed { check: (toCheck: any) => boolean | string } of
|
|
43
|
+
* **realConditions** will be verified to TRUE automatically, considering optional parameters.
|
|
44
|
+
* If an **index** is specified but the tagged parameter's value isn't an array, the **index** is treated as being undefined.
|
|
45
|
+
* If **index** is undefined and the tagged parameter's value is an {@link Array } each element of it will be checked
|
|
46
|
+
* against the **realConditions**.
|
|
47
|
+
*
|
|
48
|
+
* @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
|
|
49
|
+
* against with.
|
|
50
|
+
* @param index See the {@link AE.checkAlgorithm }.
|
|
51
|
+
* @param idxEnd See the {@link AE.checkAlgorithm }.
|
|
52
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
53
|
+
* @param hint See {@link DBC.decPrecondition }.
|
|
54
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
55
|
+
*
|
|
56
|
+
* @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of **realConditions** returns one.
|
|
57
|
+
* Otherwise TRUE. */
|
|
58
|
+
static PRE(realConditions: Array<{
|
|
59
|
+
check: (toCheck: unknown | undefined | null) => boolean | string;
|
|
60
|
+
}> | {
|
|
61
|
+
check: (toCheck: unknown | undefined | null) => boolean | string;
|
|
62
|
+
}, index?: number | undefined, idxEnd?: number | undefined, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
63
|
+
/**
|
|
64
|
+
* A method-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
|
|
65
|
+
* of the **realConditions** to check the tagged method's return-value against with.
|
|
66
|
+
*
|
|
67
|
+
* @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
|
|
68
|
+
* against with.
|
|
69
|
+
* @param index See the {@link AE.checkAlgorithm }.
|
|
70
|
+
* @param idxEnd See the {@link AE.checkAlgorithm }.
|
|
71
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
72
|
+
* @param hint See {@link DBC.decPrecondition }.
|
|
73
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
74
|
+
*
|
|
75
|
+
* @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of **realConditions** return one.
|
|
76
|
+
* Otherwise TRUE. */
|
|
77
|
+
static POST(realConditions: Array<{
|
|
78
|
+
check: (toCheck: any) => boolean | string;
|
|
79
|
+
}> | {
|
|
80
|
+
check: (toCheck: any) => boolean | string;
|
|
81
|
+
}, index?: number | undefined, idxEnd?: number | undefined, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
82
|
+
/**
|
|
83
|
+
* A field-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
|
|
84
|
+
* of the **realConditions** to check the tagged field.
|
|
85
|
+
*
|
|
86
|
+
* @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
|
|
87
|
+
* against with.
|
|
88
|
+
* @param index See the {@link AE.checkAlgorithm }.
|
|
89
|
+
* @param idxEnd See the {@link AE.checkAlgorithm }.
|
|
90
|
+
* @param path See {@link DBC.decInvariant }.
|
|
91
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
92
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
93
|
+
*
|
|
94
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
95
|
+
static INVARIANT(realConditions: Array<{
|
|
96
|
+
check: (toCheck: any) => boolean | string;
|
|
97
|
+
}> | {
|
|
98
|
+
check: (toCheck: any) => boolean | string;
|
|
99
|
+
}, index?: number | undefined, idxEnd?: number | undefined, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Invokes the {@link AE.checkAlgorithm } with all {@link AE.conditions } and the {@link object } {@link toCheck },
|
|
102
|
+
* {@link AE.index } & {@link AE.idxEnd }.
|
|
103
|
+
*
|
|
104
|
+
* @param toCheck See {@link AE.checkAlgorithm }.
|
|
105
|
+
*
|
|
106
|
+
* @returns See {@link EQ.checkAlgorithm}. */
|
|
107
|
+
check(toCheck: any): string | boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Creates this {@link AE } by setting the protected property {@link AE.conditions }, {@link AE.index } and {@link AE.idxEnd } used by {@link AE.check }.
|
|
110
|
+
*
|
|
111
|
+
* @param equivalent See {@link EQ.check }. */
|
|
112
|
+
constructor(conditions: Array<{
|
|
113
|
+
check: (toCheck: any) => boolean | string;
|
|
114
|
+
}> | {
|
|
115
|
+
check: (toCheck: any) => boolean | string;
|
|
116
|
+
}, index?: number | undefined, idxEnd?: number | undefined);
|
|
117
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { COMPARISON } from "../COMPARISON";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export declare class GREATER extends COMPARISON {
|
|
4
|
+
equivalent: any;
|
|
5
|
+
/** See {@link COMPARISON.PRE }. */
|
|
6
|
+
static PRE(equivalent: any, equalityPermitted?: boolean, invert?: boolean, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
7
|
+
/** See {@link COMPARISON.POST }. */
|
|
8
|
+
static POST(equivalent: any, equalityPermitted?: boolean, invert?: boolean, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
9
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
10
|
+
static INVARIANT(equivalent: any, equalityPermitted?: boolean, invert?: boolean, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
11
|
+
/** See {@link COMPARISON.constructor }. */
|
|
12
|
+
constructor(equivalent: any);
|
|
13
|
+
}
|