xdbc 1.0.215 → 1.0.216

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.
@@ -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): 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): CANDIDATE;
63
+ /**
64
+ * Creates this {@link ARRAY } instance. No parameters needed — the check is always {@link Array.isArray }. */
65
+ constructor();
66
+ }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.215",
2
+ "version": "1.0.216",
3
3
  "name": "xdbc",
4
4
  "main": "dist/bundle.js",
5
5
  "types": "dist/DBC.d.ts",
@@ -0,0 +1,130 @@
1
+ import { DBC } from "../../DBC";
2
+ import { ARRAY } from "../ARRAY";
3
+ /**
4
+ * A {@link DBC } defining that a value must be a plain object — i.e. `typeof value === "object"`,
5
+ * not `null`, and not an array.
6
+ *
7
+ * @remarks
8
+ * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
9
+ export class PLAIN_OBJECT extends ARRAY {
10
+ /**
11
+ * Checks if the value **toCheck** is a plain object (non-null, non-array object).
12
+ *
13
+ * @param toCheck The value to check.
14
+ *
15
+ * @returns TRUE if the value **toCheck** is a plain object, otherwise a string describing the infringement. */
16
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic type checking.
17
+ public static checkAlgorithm(toCheck: any): boolean | string {
18
+ if (toCheck === undefined || toCheck === null) return true;
19
+
20
+ if (typeof toCheck !== "object") {
21
+ return `Value has to be a PLAIN_OBJECT but is of type "${typeof toCheck}"`;
22
+ }
23
+
24
+ if (Array.isArray(toCheck)) {
25
+ return "Value has to be a PLAIN_OBJECT but is an ARRAY";
26
+ }
27
+
28
+ return true;
29
+ }
30
+ /**
31
+ * A parameter-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
32
+ * by the tagged parameter.
33
+ *
34
+ * @param path See {@link DBC.decPrecondition }.
35
+ * @param hint See {@link DBC.decPrecondition }.
36
+ * @param dbc See {@link DBC.decPrecondition }.
37
+ *
38
+ * @returns See {@link DBC.decPrecondition }. */
39
+ public static PRE(
40
+ path: string | undefined = undefined,
41
+ hint: string | undefined = undefined,
42
+ dbc: string | undefined = undefined,
43
+ ): (
44
+ target: object,
45
+ methodName: string | symbol | undefined,
46
+ parameterIndex: number,
47
+ ) => void {
48
+ return DBC.createPRE(PLAIN_OBJECT.checkAlgorithm, [], dbc, path, hint);
49
+ }
50
+ /**
51
+ * A method-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
52
+ * by the tagged method's returnvalue.
53
+ *
54
+ * @param path See {@link DBC.decPostcondition }.
55
+ * @param hint See {@link DBC.decPostcondition }.
56
+ * @param dbc See {@link DBC.decPostcondition }.
57
+ *
58
+ * @returns See {@link DBC.decPostcondition }. */
59
+ public static POST(
60
+ path: string | undefined = undefined,
61
+ hint: string | undefined = undefined,
62
+ dbc: string | undefined = undefined,
63
+ ): (
64
+ target: object,
65
+ propertyKey: string,
66
+ descriptor: PropertyDescriptor,
67
+ ) => PropertyDescriptor {
68
+ return DBC.createPOST(PLAIN_OBJECT.checkAlgorithm, [], dbc, path, hint);
69
+ }
70
+ /**
71
+ * A field-decorator factory using the {@link PLAIN_OBJECT.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
72
+ * by the tagged field.
73
+ *
74
+ * @param path See {@link DBC.decInvariant }.
75
+ * @param hint See {@link DBC.decInvariant }.
76
+ * @param dbc See {@link DBC.decInvariant }.
77
+ *
78
+ * @returns See {@link DBC.decInvariant }. */
79
+ public static INVARIANT(
80
+ path: string | undefined = undefined,
81
+ hint: string | undefined = undefined,
82
+ dbc: string | undefined = undefined,
83
+ ) {
84
+ return DBC.createINVARIANT(PLAIN_OBJECT, [], dbc, path, hint);
85
+ }
86
+ // #endregion Condition checking.
87
+ // #region Referenced Condition checking.
88
+ //
89
+ // For usage in dynamic scenarios (like with AE-DBC).
90
+ //
91
+ /**
92
+ * Invokes the {@link PLAIN_OBJECT.checkAlgorithm } passing the value **toCheck**.
93
+ *
94
+ * @param toCheck See {@link PLAIN_OBJECT.checkAlgorithm }.
95
+ *
96
+ * @returns See {@link PLAIN_OBJECT.checkAlgorithm}. */
97
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
98
+ public check(toCheck: any) {
99
+ return PLAIN_OBJECT.checkAlgorithm(toCheck);
100
+ }
101
+ /**
102
+ * Invokes the {@link PLAIN_OBJECT.checkAlgorithm } passing the value **toCheck**.
103
+ *
104
+ * @param toCheck See {@link PLAIN_OBJECT.checkAlgorithm }.
105
+ * @param hint An optional {@link string } providing extra information in case of an infringement.
106
+ * @param id A {@link string } identifying this {@link PLAIN_OBJECT } via the {@link DBC.Infringement }-Message.
107
+ *
108
+ * @returns The **CANDIDATE** **toCheck** if this {@link PLAIN_OBJECT } is fulfilled.
109
+ *
110
+ * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link PLAIN_OBJECT }. */
111
+ public static tsCheck<CANDIDATE extends object = object>(
112
+ toCheck: CANDIDATE | undefined | null,
113
+ hint: string | undefined = undefined,
114
+ id: string | undefined = undefined,
115
+ ): CANDIDATE {
116
+ const result = PLAIN_OBJECT.checkAlgorithm(toCheck);
117
+
118
+ if (result === true) {
119
+ return toCheck as CANDIDATE;
120
+ }
121
+ throw new DBC.Infringement(
122
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
123
+ );
124
+ }
125
+ /**
126
+ * Creates this {@link PLAIN_OBJECT } instance. No parameters needed — the check is always the same. */
127
+ public constructor() {
128
+ super();
129
+ }
130
+ }
@@ -0,0 +1,124 @@
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 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
+ // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic type checking.
15
+ public static checkAlgorithm(toCheck: any): boolean | string {
16
+ if (toCheck === undefined || toCheck === null) return true;
17
+
18
+ if (!Array.isArray(toCheck)) {
19
+ return `Value has to be an ARRAY but is of type "${typeof toCheck}"`;
20
+ }
21
+
22
+ return true;
23
+ }
24
+ /**
25
+ * A parameter-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
26
+ * by the tagged parameter.
27
+ *
28
+ * @param path See {@link DBC.decPrecondition }.
29
+ * @param hint See {@link DBC.decPrecondition }.
30
+ * @param dbc See {@link DBC.decPrecondition }.
31
+ *
32
+ * @returns See {@link DBC.decPrecondition }. */
33
+ public static PRE(
34
+ path: string | undefined = undefined,
35
+ hint: string | undefined = undefined,
36
+ dbc: string | undefined = undefined,
37
+ ): (
38
+ target: object,
39
+ methodName: string | symbol | undefined,
40
+ parameterIndex: number,
41
+ ) => void {
42
+ return DBC.createPRE(ARRAY.checkAlgorithm, [], dbc, path, hint);
43
+ }
44
+ /**
45
+ * A method-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
46
+ * by the tagged method's returnvalue.
47
+ *
48
+ * @param path See {@link DBC.decPostcondition }.
49
+ * @param hint See {@link DBC.decPostcondition }.
50
+ * @param dbc See {@link DBC.decPostcondition }.
51
+ *
52
+ * @returns See {@link DBC.decPostcondition }. */
53
+ public static POST(
54
+ path: string | undefined = undefined,
55
+ hint: string | undefined = undefined,
56
+ dbc: string | undefined = undefined,
57
+ ): (
58
+ target: object,
59
+ propertyKey: string,
60
+ descriptor: PropertyDescriptor,
61
+ ) => PropertyDescriptor {
62
+ return DBC.createPOST(ARRAY.checkAlgorithm, [], dbc, path, hint);
63
+ }
64
+ /**
65
+ * A field-decorator factory using the {@link ARRAY.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
66
+ * by the tagged field.
67
+ *
68
+ * @param path See {@link DBC.decInvariant }.
69
+ * @param hint See {@link DBC.decInvariant }.
70
+ * @param dbc See {@link DBC.decInvariant }.
71
+ *
72
+ * @returns See {@link DBC.decInvariant }. */
73
+ public static INVARIANT(
74
+ path: string | undefined = undefined,
75
+ hint: string | undefined = undefined,
76
+ dbc: string | undefined = undefined,
77
+ ) {
78
+ return DBC.createINVARIANT(ARRAY, [], dbc, path, hint);
79
+ }
80
+ // #endregion Condition checking.
81
+ // #region Referenced Condition checking.
82
+ //
83
+ // For usage in dynamic scenarios (like with AE-DBC).
84
+ //
85
+ /**
86
+ * Invokes the {@link ARRAY.checkAlgorithm } passing the value **toCheck**.
87
+ *
88
+ * @param toCheck See {@link ARRAY.checkAlgorithm }.
89
+ *
90
+ * @returns See {@link ARRAY.checkAlgorithm}. */
91
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
92
+ public check(toCheck: any) {
93
+ return ARRAY.checkAlgorithm(toCheck);
94
+ }
95
+ /**
96
+ * Invokes the {@link ARRAY.checkAlgorithm } passing the value **toCheck**.
97
+ *
98
+ * @param toCheck See {@link ARRAY.checkAlgorithm }.
99
+ * @param hint An optional {@link string } providing extra information in case of an infringement.
100
+ * @param id A {@link string } identifying this {@link ARRAY } via the {@link DBC.Infringement }-Message.
101
+ *
102
+ * @returns The **CANDIDATE** **toCheck** if this {@link ARRAY } is fulfilled.
103
+ *
104
+ * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link ARRAY }. */
105
+ public static tsCheck<CANDIDATE extends unknown[] = unknown[]>(
106
+ toCheck: CANDIDATE | undefined | null,
107
+ hint: string | undefined = undefined,
108
+ id: string | undefined = undefined,
109
+ ): CANDIDATE {
110
+ const result = ARRAY.checkAlgorithm(toCheck);
111
+
112
+ if (result === true) {
113
+ return toCheck as CANDIDATE;
114
+ }
115
+ throw new DBC.Infringement(
116
+ `${id ? `(${id}) ` : ""}${result as string}${hint ? ` ✨ ${hint} ✨` : ""}`,
117
+ );
118
+ }
119
+ /**
120
+ * Creates this {@link ARRAY } instance. No parameters needed — the check is always {@link Array.isArray }. */
121
+ public constructor() {
122
+ super();
123
+ }
124
+ }