xdbc 1.0.215 → 1.0.217
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/README.md +2 -0
- package/__tests__/DBC/ARRAY.test.ts +91 -0
- package/__tests__/DBC/PLAIN_OBJECT.test.ts +109 -0
- package/dist/DBC/ARR/PLAIN_OBJECT.d.ts +67 -0
- package/dist/DBC/ARRAY.d.ts +66 -0
- package/dist/DBC/DEFINED.d.ts +1 -1
- package/dist/DBC/EQ.d.ts +1 -1
- package/dist/DBC/INSTANCE.d.ts +2 -2
- package/dist/DBC/JSON.OP.d.ts +1 -1
- package/dist/DBC/JSON.Parse.d.ts +1 -1
- package/dist/DBC/OR.d.ts +1 -1
- package/dist/DBC/REGEX.d.ts +2 -2
- package/dist/DBC/TYPE.d.ts +1 -1
- package/dist/DBC/UNDEFINED.d.ts +1 -1
- package/dist/DBC/ZOD.d.ts +1 -1
- package/dist/DBC.d.ts +9 -0
- package/dist/bundle.js +41 -14
- package/package.json +1 -1
- package/src/DBC/ARR/PLAIN_OBJECT.ts +133 -0
- package/src/DBC/ARRAY.ts +127 -0
- package/src/DBC/DEFINED.ts +4 -1
- package/src/DBC/EQ.ts +5 -2
- package/src/DBC/INSTANCE.ts +6 -2
- package/src/DBC/JSON.OP.ts +2 -1
- package/src/DBC/JSON.Parse.ts +2 -1
- package/src/DBC/OR.ts +4 -1
- package/src/DBC/REGEX.ts +6 -3
- package/src/DBC/TYPE.ts +4 -1
- package/src/DBC/UNDEFINED.ts +3 -1
- package/src/DBC/ZOD.ts +3 -1
- package/src/DBC.ts +27 -0
package/README.md
CHANGED
|
@@ -149,6 +149,7 @@ XDBC ships with **16 contracts** organized into core validators and derived spec
|
|
|
149
149
|
| **`JSON_Parse`** | String must be valid JSON; optionally forwards parsed result | `new JSON_Parse(receptor?: (json) => void)` |
|
|
150
150
|
| **`DEFINED`** | Value must not be `null` or `undefined` | — |
|
|
151
151
|
| **`UNDEFINED`** | Value must be `undefined` | — |
|
|
152
|
+
| **`ARRAY`** | Value must be an array | — |
|
|
152
153
|
| **`HasAttribute`** | HTMLElement must possess a named attribute | `HasAttribute.PRE(attrName, invert?)` |
|
|
153
154
|
| **`ZOD`** | Value must validate against a Zod schema | `new ZOD(schema: z.ZodType)` |
|
|
154
155
|
|
|
@@ -161,6 +162,7 @@ XDBC ships with **16 contracts** organized into core validators and derived spec
|
|
|
161
162
|
| **`LESS`** | `COMPARISON` | `value < reference` |
|
|
162
163
|
| **`LESS_OR_EQUAL`** | `COMPARISON` | `value <= reference` |
|
|
163
164
|
| **`DIFFERENT`** | `EQ` | `value !== reference` |
|
|
165
|
+
| **`PLAIN_OBJECT`** | `ARRAY` | Value must be a non-null, non-array object |
|
|
164
166
|
|
|
165
167
|
### Built-in Regular Expressions
|
|
166
168
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ARRAY } from "../../src/DBC/ARRAY";
|
|
2
|
+
import { DBC } from "../../src/DBC";
|
|
3
|
+
|
|
4
|
+
describe("ARRAY", () => {
|
|
5
|
+
const array = new ARRAY();
|
|
6
|
+
|
|
7
|
+
test("Should not report infringement with an array", () => {
|
|
8
|
+
expect(array.check([1, 2, 3])).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("Should not report infringement with an empty array", () => {
|
|
12
|
+
expect(array.check([])).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("Should not report infringement with undefined (null-passthrough)", () => {
|
|
16
|
+
expect(array.check(undefined)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("Should not report infringement with null (null-passthrough)", () => {
|
|
20
|
+
expect(array.check(null)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("Should report infringement with a plain object", () => {
|
|
24
|
+
expect(typeof array.check({})).toBe("string");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("Should report infringement with a string", () => {
|
|
28
|
+
expect(typeof array.check("hello")).toBe("string");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("Should report infringement with a number", () => {
|
|
32
|
+
expect(typeof array.check(42)).toBe("string");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("checkAlgorithm", () => {
|
|
36
|
+
test("Should return true for an array", () => {
|
|
37
|
+
expect(ARRAY.checkAlgorithm([1, 2, 3])).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("Should return true for an empty array", () => {
|
|
41
|
+
expect(ARRAY.checkAlgorithm([])).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Should return true for null (null-passthrough)", () => {
|
|
45
|
+
expect(ARRAY.checkAlgorithm(null)).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Should return true for undefined (null-passthrough)", () => {
|
|
49
|
+
expect(ARRAY.checkAlgorithm(undefined)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("Should return string for a plain object", () => {
|
|
53
|
+
const result = ARRAY.checkAlgorithm({});
|
|
54
|
+
expect(typeof result).toBe("string");
|
|
55
|
+
expect(result).toContain("ARRAY");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("Should return string for a string value", () => {
|
|
59
|
+
const result = ARRAY.checkAlgorithm("hello");
|
|
60
|
+
expect(typeof result).toBe("string");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("Should return string for a number", () => {
|
|
64
|
+
const result = ARRAY.checkAlgorithm(42);
|
|
65
|
+
expect(typeof result).toBe("string");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("tsCheck", () => {
|
|
70
|
+
test("Should return the value when it is an array", () => {
|
|
71
|
+
const value = [1, 2, 3];
|
|
72
|
+
expect(ARRAY.tsCheck(value)).toBe(value);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("Should throw DBC.Infringement when value is not an array", () => {
|
|
76
|
+
expect(() => ARRAY.tsCheck({} as any)).toThrow(DBC.Infringement);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("Should include hint in the infringement message", () => {
|
|
80
|
+
expect(() => ARRAY.tsCheck("oops" as any, "must be an array")).toThrow(
|
|
81
|
+
/must be an array/,
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("Should include id in the infringement message", () => {
|
|
86
|
+
expect(() => ARRAY.tsCheck(42 as any, undefined, "myParam")).toThrow(
|
|
87
|
+
/myParam/,
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { PLAIN_OBJECT } from "../../src/DBC/ARR/PLAIN_OBJECT";
|
|
2
|
+
import { DBC } from "../../src/DBC";
|
|
3
|
+
|
|
4
|
+
describe("PLAIN_OBJECT", () => {
|
|
5
|
+
const plainObject = new PLAIN_OBJECT();
|
|
6
|
+
|
|
7
|
+
test("Should not report infringement with a plain object", () => {
|
|
8
|
+
expect(plainObject.check({ a: 1 })).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("Should not report infringement with an empty object", () => {
|
|
12
|
+
expect(plainObject.check({})).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("Should not report infringement with undefined (null-passthrough)", () => {
|
|
16
|
+
expect(plainObject.check(undefined)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("Should not report infringement with null (null-passthrough)", () => {
|
|
20
|
+
expect(plainObject.check(null)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("Should report infringement with an array", () => {
|
|
24
|
+
expect(typeof plainObject.check([])).toBe("string");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("Should report infringement with a non-empty array", () => {
|
|
28
|
+
expect(typeof plainObject.check([1, 2, 3])).toBe("string");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("Should report infringement with a string", () => {
|
|
32
|
+
expect(typeof plainObject.check("hello")).toBe("string");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("Should report infringement with a number", () => {
|
|
36
|
+
expect(typeof plainObject.check(42)).toBe("string");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("checkAlgorithm", () => {
|
|
40
|
+
test("Should return true for a plain object", () => {
|
|
41
|
+
expect(PLAIN_OBJECT.checkAlgorithm({ key: "value" })).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Should return true for an empty object", () => {
|
|
45
|
+
expect(PLAIN_OBJECT.checkAlgorithm({})).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Should return true for null (null-passthrough)", () => {
|
|
49
|
+
expect(PLAIN_OBJECT.checkAlgorithm(null)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("Should return true for undefined (null-passthrough)", () => {
|
|
53
|
+
expect(PLAIN_OBJECT.checkAlgorithm(undefined)).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("Should return string for an array", () => {
|
|
57
|
+
const result = PLAIN_OBJECT.checkAlgorithm([]);
|
|
58
|
+
expect(typeof result).toBe("string");
|
|
59
|
+
expect(result).toContain("ARRAY");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("Should return string for a non-empty array", () => {
|
|
63
|
+
const result = PLAIN_OBJECT.checkAlgorithm([1, 2, 3]);
|
|
64
|
+
expect(typeof result).toBe("string");
|
|
65
|
+
expect(result).toContain("ARRAY");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("Should return string for a string value", () => {
|
|
69
|
+
const result = PLAIN_OBJECT.checkAlgorithm("hello");
|
|
70
|
+
expect(typeof result).toBe("string");
|
|
71
|
+
expect(result).toContain("PLAIN_OBJECT");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("Should return string for a number", () => {
|
|
75
|
+
const result = PLAIN_OBJECT.checkAlgorithm(42);
|
|
76
|
+
expect(typeof result).toBe("string");
|
|
77
|
+
expect(result).toContain("PLAIN_OBJECT");
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("tsCheck", () => {
|
|
82
|
+
test("Should return the value when it is a plain object", () => {
|
|
83
|
+
const value = { x: 1 };
|
|
84
|
+
expect(PLAIN_OBJECT.tsCheck(value)).toBe(value);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("Should throw DBC.Infringement when value is an array", () => {
|
|
88
|
+
expect(() => PLAIN_OBJECT.tsCheck([] as any)).toThrow(DBC.Infringement);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("Should throw DBC.Infringement when value is a string", () => {
|
|
92
|
+
expect(() => PLAIN_OBJECT.tsCheck("oops" as any)).toThrow(
|
|
93
|
+
DBC.Infringement,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("Should include hint in the infringement message", () => {
|
|
98
|
+
expect(() =>
|
|
99
|
+
PLAIN_OBJECT.tsCheck([] as any, "must be a plain object"),
|
|
100
|
+
).toThrow(/must be a plain object/);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("Should include id in the infringement message", () => {
|
|
104
|
+
expect(() =>
|
|
105
|
+
PLAIN_OBJECT.tsCheck(42 as any, undefined, "optionsParam"),
|
|
106
|
+
).toThrow(/optionsParam/);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ARRAY } from "../ARRAY";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that a value must be a plain object — i.e. `typeof value === "object"`,
|
|
4
|
+
* not `null`, and not an array.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
8
|
+
export declare class PLAIN_OBJECT extends ARRAY {
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the value **toCheck** is a plain object (non-null, non-array object).
|
|
11
|
+
*
|
|
12
|
+
* @param toCheck The value to check.
|
|
13
|
+
*
|
|
14
|
+
* @returns TRUE if the value **toCheck** is a plain object, otherwise a string describing the infringement. */
|
|
15
|
+
static checkAlgorithm(toCheck: any): boolean | string;
|
|
16
|
+
/**
|
|
17
|
+
* A parameter-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
18
|
+
* by the tagged parameter.
|
|
19
|
+
*
|
|
20
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
21
|
+
* @param hint See {@link DBC.decPrecondition }.
|
|
22
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
23
|
+
*
|
|
24
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
25
|
+
static PRE(path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
26
|
+
/**
|
|
27
|
+
* A method-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
28
|
+
* by the tagged method's returnvalue.
|
|
29
|
+
*
|
|
30
|
+
* @param path See {@link DBC.decPostcondition }.
|
|
31
|
+
* @param hint See {@link DBC.decPostcondition }.
|
|
32
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
33
|
+
*
|
|
34
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
35
|
+
static POST(path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
36
|
+
/**
|
|
37
|
+
* A field-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
38
|
+
* by the tagged field.
|
|
39
|
+
*
|
|
40
|
+
* @param path See {@link DBC.decInvariant }.
|
|
41
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
42
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
43
|
+
*
|
|
44
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
45
|
+
static INVARIANT(path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Invokes the {@link PLAIN_OBJECT.checkAlgorithm } passing the value **toCheck**.
|
|
48
|
+
*
|
|
49
|
+
* @param toCheck See {@link PLAIN_OBJECT.checkAlgorithm }.
|
|
50
|
+
*
|
|
51
|
+
* @returns See {@link PLAIN_OBJECT.checkAlgorithm}. */
|
|
52
|
+
check(toCheck: any): string | boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Invokes the {@link PLAIN_OBJECT.checkAlgorithm } passing the value **toCheck**.
|
|
55
|
+
*
|
|
56
|
+
* @param toCheck See {@link PLAIN_OBJECT.checkAlgorithm }.
|
|
57
|
+
* @param hint An optional {@link string } providing extra information in case of an infringement.
|
|
58
|
+
* @param id A {@link string } identifying this {@link PLAIN_OBJECT } via the {@link DBC.Infringement }-Message.
|
|
59
|
+
*
|
|
60
|
+
* @returns The **CANDIDATE** **toCheck** if this {@link PLAIN_OBJECT } is fulfilled.
|
|
61
|
+
*
|
|
62
|
+
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link PLAIN_OBJECT }. */
|
|
63
|
+
static tsCheck<CANDIDATE extends object = object>(toCheck: CANDIDATE | undefined | null, hint?: string | undefined, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
64
|
+
/**
|
|
65
|
+
* Creates this {@link PLAIN_OBJECT } instance. No parameters needed — the check is always the same. */
|
|
66
|
+
constructor();
|
|
67
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that a value must be an array.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
+
export declare class ARRAY extends DBC {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the value **toCheck** is an array.
|
|
10
|
+
*
|
|
11
|
+
* @param toCheck The value to check.
|
|
12
|
+
*
|
|
13
|
+
* @returns TRUE if the value **toCheck** is an array, otherwise a string describing the infringement. */
|
|
14
|
+
static checkAlgorithm(toCheck: any): boolean | string;
|
|
15
|
+
/**
|
|
16
|
+
* A parameter-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
17
|
+
* by the tagged parameter.
|
|
18
|
+
*
|
|
19
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
20
|
+
* @param hint See {@link DBC.decPrecondition }.
|
|
21
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
22
|
+
*
|
|
23
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
24
|
+
static PRE(path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
25
|
+
/**
|
|
26
|
+
* A method-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
27
|
+
* by the tagged method's returnvalue.
|
|
28
|
+
*
|
|
29
|
+
* @param path See {@link DBC.decPostcondition }.
|
|
30
|
+
* @param hint See {@link DBC.decPostcondition }.
|
|
31
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
32
|
+
*
|
|
33
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
34
|
+
static POST(path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
35
|
+
/**
|
|
36
|
+
* A field-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
37
|
+
* by the tagged field.
|
|
38
|
+
*
|
|
39
|
+
* @param path See {@link DBC.decInvariant }.
|
|
40
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
41
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
42
|
+
*
|
|
43
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
44
|
+
static INVARIANT(path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Invokes the {@link ARRAY.checkAlgorithm } passing the value **toCheck**.
|
|
47
|
+
*
|
|
48
|
+
* @param toCheck See {@link ARRAY.checkAlgorithm }.
|
|
49
|
+
*
|
|
50
|
+
* @returns See {@link ARRAY.checkAlgorithm}. */
|
|
51
|
+
check(toCheck: any): string | boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Invokes the {@link ARRAY.checkAlgorithm } passing the value **toCheck**.
|
|
54
|
+
*
|
|
55
|
+
* @param toCheck See {@link ARRAY.checkAlgorithm }.
|
|
56
|
+
* @param hint An optional {@link string } providing extra information in case of an infringement.
|
|
57
|
+
* @param id A {@link string } identifying this {@link ARRAY } via the {@link DBC.Infringement }-Message.
|
|
58
|
+
*
|
|
59
|
+
* @returns The **CANDIDATE** **toCheck** if this {@link ARRAY } is fulfilled.
|
|
60
|
+
*
|
|
61
|
+
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link ARRAY }. */
|
|
62
|
+
static tsCheck<CANDIDATE extends unknown[] = unknown[]>(toCheck: CANDIDATE | undefined | null, hint?: string | undefined, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
63
|
+
/**
|
|
64
|
+
* Creates this {@link ARRAY } instance. No parameters needed — the check is always {@link Array.isArray }. */
|
|
65
|
+
constructor();
|
|
66
|
+
}
|
package/dist/DBC/DEFINED.d.ts
CHANGED
|
@@ -58,5 +58,5 @@ export declare class DEFINED extends DBC {
|
|
|
58
58
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link DEFINED }.
|
|
59
59
|
*
|
|
60
60
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }.*/
|
|
61
|
-
static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint?: string | undefined, id?: string | undefined): CANDIDATE;
|
|
61
|
+
static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, hint?: string | undefined, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
62
62
|
}
|
package/dist/DBC/EQ.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare class EQ extends DBC {
|
|
|
61
61
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link EQ }.
|
|
62
62
|
*
|
|
63
63
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link EQ }.*/
|
|
64
|
-
static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint?: string | undefined, id?: string | undefined): CANDIDATE;
|
|
64
|
+
static tsCheck<CANDIDATE>(toCheck: CANDIDATE | undefined | null, equivalent: any, hint?: string | undefined, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
65
65
|
/**
|
|
66
66
|
* Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
|
|
67
67
|
*
|
package/dist/DBC/INSTANCE.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare class INSTANCE extends DBC {
|
|
|
63
63
|
* @returns The **CANDIDATE** **toCheck** if it fulfills this {@link INSTANCE }.
|
|
64
64
|
*
|
|
65
65
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link INSTANCE }. */
|
|
66
|
-
static tsCheck<CANDIDATE = unknown>(toCheck: any, reference: any, hint?: string, id?: string | undefined): CANDIDATE;
|
|
66
|
+
static tsCheck<CANDIDATE = unknown>(toCheck: any, reference: any, hint?: string, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
67
67
|
/**
|
|
68
68
|
* Invokes the {@link INSTANCE.checkAlgorithm } passing the value **toCheck** and the {@link INSTANCE.reference } .
|
|
69
69
|
*
|
|
@@ -75,7 +75,7 @@ export declare class INSTANCE extends DBC {
|
|
|
75
75
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link INSTANCE }.
|
|
76
76
|
*
|
|
77
77
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
|
|
78
|
-
static tsCheckMulti<CANDIDATE = unknown>(toCheck: any, references: any[], hint?: string, id?: string | undefined): CANDIDATE;
|
|
78
|
+
static tsCheckMulti<CANDIDATE = unknown>(toCheck: any, references: any[], hint?: string, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
79
79
|
/**
|
|
80
80
|
* Creates this {@link INSTANCE } by setting the protected property {@link INSTANCE.reference } used by {@link INSTANCE.check }.
|
|
81
81
|
*
|
package/dist/DBC/JSON.OP.d.ts
CHANGED
package/dist/DBC/JSON.Parse.d.ts
CHANGED
|
@@ -65,5 +65,5 @@ export declare class JSON_Parse extends DBC {
|
|
|
65
65
|
* @param necessaryProperties See {@link JSON_Parse.checkAlgorithm} }.
|
|
66
66
|
* @param checkElements See {@link JSON_Parse.checkAlgorithm} }.
|
|
67
67
|
*/
|
|
68
|
-
static check(toCheck: any, receptor: (json: object) => void): void;
|
|
68
|
+
static check(toCheck: any, receptor: (json: object) => void, dbc?: string | undefined): void;
|
|
69
69
|
}
|
package/dist/DBC/OR.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export declare class OR extends DBC {
|
|
|
93
93
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link OR }.*/
|
|
94
94
|
static tsCheck<CANDIDATE>(toCheck: unknown | undefined | null, conditions: Array<{
|
|
95
95
|
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
96
|
-
}>, hint?: string, id?: string | undefined): CANDIDATE;
|
|
96
|
+
}>, hint?: string, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
97
97
|
/**
|
|
98
98
|
* Creates this {@link OR } by setting the protected property {@link OR.conditions } used by {@link OR.check }.
|
|
99
99
|
*
|
package/dist/DBC/REGEX.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export declare class REGEX extends DBC {
|
|
|
80
80
|
* @returns The validated value cast to the CANDIDATE type.
|
|
81
81
|
*
|
|
82
82
|
* @throws {@link DBC.Infringement} if the value does not match the regular expression. */
|
|
83
|
-
static tsCheck<CANDIDATE = unknown>(toCheck: any, expression: RegExp, hint?: string | undefined, id?: string | undefined): CANDIDATE;
|
|
83
|
+
static tsCheck<CANDIDATE = unknown>(toCheck: any, expression: RegExp, hint?: string | undefined, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
84
84
|
/**
|
|
85
85
|
* Creates this {@link REGEX } by setting the protected property {@link REGEX.expression } used by {@link REGEX.check }.
|
|
86
86
|
*
|
|
@@ -92,5 +92,5 @@ export declare class REGEX extends DBC {
|
|
|
92
92
|
* @param toCheck See {@link REGEX.checkAlgorithm}.
|
|
93
93
|
* @param expression See {@link REGEX.checkAlgorithm}.
|
|
94
94
|
*/
|
|
95
|
-
static check(toCheck: unknown | null | undefined, expression: RegExp): void;
|
|
95
|
+
static check(toCheck: unknown | null | undefined, expression: RegExp, dbc?: string | undefined): void;
|
|
96
96
|
}
|
package/dist/DBC/TYPE.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare class TYPE extends DBC {
|
|
|
66
66
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link TYPE }.
|
|
67
67
|
*
|
|
68
68
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
|
|
69
|
-
static tsCheck<CANDIDATE = unknown>(toCheck: any, type: string, hint?: string | undefined, id?: string | undefined): CANDIDATE;
|
|
69
|
+
static tsCheck<CANDIDATE = unknown>(toCheck: any, type: string, hint?: string | undefined, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
70
70
|
/**
|
|
71
71
|
* Creates this {@link TYPE } by setting the protected property {@link TYPE.type } used by {@link TYPE.check }.
|
|
72
72
|
*
|
package/dist/DBC/UNDEFINED.d.ts
CHANGED
|
@@ -58,5 +58,5 @@ export declare class UNDEFINED extends DBC {
|
|
|
58
58
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link UNDEFINED }.
|
|
59
59
|
*
|
|
60
60
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link UNDEFINED }.*/
|
|
61
|
-
static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, id?: string | undefined): CANDIDATE;
|
|
61
|
+
static tsCheck<CANDIDATE = unknown>(toCheck: CANDIDATE | undefined | null, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
62
62
|
}
|
package/dist/DBC/ZOD.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare class ZOD extends DBC {
|
|
|
63
63
|
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link ZOD }.
|
|
64
64
|
*
|
|
65
65
|
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
|
|
66
|
-
static tsCheck<CANDIDATE = unknown>(toCheck: any, schema: z.ZodType, id?: string | undefined): CANDIDATE;
|
|
66
|
+
static tsCheck<CANDIDATE = unknown>(toCheck: any, schema: z.ZodType, id?: string | undefined, dbc?: string | undefined): CANDIDATE;
|
|
67
67
|
/**
|
|
68
68
|
* Creates this {@link ZOD } by setting the protected property {@link ZOD.schema } used by {@link ZOD.check }.
|
|
69
69
|
*
|
package/dist/DBC.d.ts
CHANGED
|
@@ -185,6 +185,15 @@ export declare class DBC {
|
|
|
185
185
|
* @param method The {@link string } describing or naming the violator.
|
|
186
186
|
* @param value The parameter's value. */
|
|
187
187
|
reportReturnvalueInfringement(message: string, target: object, path: string | undefined, method: string, value: any, hint?: string | undefined): void;
|
|
188
|
+
/**
|
|
189
|
+
* Routes an imperative infringement (from {@link tsCheck } or static {@link check } calls) through the
|
|
190
|
+
* registered DBC instance's {@link infringementSettings }, respecting whether to throw, log, or both.
|
|
191
|
+
* Falls back to throwing {@link DBC.Infringement } directly if no DBC instance is registered at the
|
|
192
|
+
* specified path, preserving the pre-existing behaviour for code that does not register a DBC instance.
|
|
193
|
+
*
|
|
194
|
+
* @param message The fully formatted infringement message.
|
|
195
|
+
* @param dbc The path to the DBC instance. Defaults to `"WaXCode.DBC"`. */
|
|
196
|
+
static reportTsCheckInfringement(message: string, dbc?: string | undefined): void;
|
|
188
197
|
/** An {@link Error } to be thrown whenever an infringement is detected. */
|
|
189
198
|
static Infringement: {
|
|
190
199
|
new (message: string): {
|