xdbc 1.0.211 → 1.0.212
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/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 +12 -1
- 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 +2 -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
|
+
}
|