xdbc 1.0.207 → 1.0.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/Assessment.html +350 -0
  2. package/Assessment.md +507 -51
  3. package/CHANGELOG.md +55 -0
  4. package/CONTRIBUTING.md +129 -17
  5. package/README.md +373 -71
  6. package/SECURITY.md +60 -18
  7. package/SUPPORT.md +65 -0
  8. package/__tests__/DBC/DEFINED.test.ts +53 -0
  9. package/__tests__/DBC/Decorators.test.ts +365 -0
  10. package/__tests__/DBC/GREATER.test.ts +8 -6
  11. package/__tests__/DBC/HasAttribute.test.ts +56 -0
  12. package/__tests__/DBC/IF.test.ts +52 -0
  13. package/__tests__/DBC/JSON.Parse.test.ts +1 -1
  14. package/__tests__/DBC/OR.test.ts +1 -1
  15. package/__tests__/DBC/REGEX.test.ts +1 -1
  16. package/__tests__/DBC/TYPE.test.ts +1 -1
  17. package/__tests__/DBC/UNDEFINED.test.ts +45 -0
  18. package/__tests__/DBC/ZOD.test.ts +54 -0
  19. package/jest.config.js +21 -0
  20. package/package.json +4 -5
  21. package/src/DBC/AE.ts +10 -6
  22. package/src/DBC/COMPARISON/GREATER.ts +11 -7
  23. package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +14 -10
  24. package/src/DBC/COMPARISON/LESS.ts +14 -10
  25. package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +14 -10
  26. package/src/DBC/COMPARISON.ts +20 -43
  27. package/src/DBC/DEFINED.ts +4 -23
  28. package/src/DBC/EQ/DIFFERENT.ts +21 -56
  29. package/src/DBC/EQ.ts +7 -26
  30. package/src/DBC/HasAttribute.ts +9 -26
  31. package/src/DBC/IF.ts +8 -27
  32. package/src/DBC/INSTANCE.ts +5 -22
  33. package/src/DBC/JSON.OP.ts +4 -34
  34. package/src/DBC/JSON.Parse.ts +5 -25
  35. package/src/DBC/OR.ts +5 -14
  36. package/src/DBC/REGEX.ts +41 -40
  37. package/src/DBC/TYPE.ts +6 -25
  38. package/src/DBC/UNDEFINED.ts +3 -22
  39. package/src/DBC/ZOD.ts +10 -27
  40. package/src/DBC.ts +223 -55
  41. package/tsconfig.json +7 -4
  42. package/tsconfig.test.json +12 -0
  43. package/.parcel-cache/bf96c58b6061a62a-BundleGraph +0 -0
  44. package/.parcel-cache/d7c812d65aeeac59-AssetGraph +0 -0
  45. package/.parcel-cache/data.mdb +0 -0
  46. package/.parcel-cache/e81759c1f106a17f-RequestGraph +0 -0
  47. package/.parcel-cache/fe0db3c4eb428be2-AssetGraph +0 -0
  48. package/.parcel-cache/lock.mdb +0 -0
  49. package/.parcel-cache/snapshot-e81759c1f106a17f.txt +0 -4609
  50. package/dist/DBC/AE.js +0 -173
  51. package/dist/DBC/COMPARISON/GREATER.js +0 -21
  52. package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +0 -21
  53. package/dist/DBC/COMPARISON/LESS.js +0 -21
  54. package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +0 -21
  55. package/dist/DBC/COMPARISON.js +0 -99
  56. package/dist/DBC/DEFINED.js +0 -99
  57. package/dist/DBC/EQ/DIFFERENT.js +0 -21
  58. package/dist/DBC/EQ.js +0 -100
  59. package/dist/DBC/GREATER.js +0 -99
  60. package/dist/DBC/HasAttribute.js +0 -108
  61. package/dist/DBC/IF.js +0 -99
  62. package/dist/DBC/INSTANCE.js +0 -93
  63. package/dist/DBC/JSON.OP.js +0 -133
  64. package/dist/DBC/JSON.Parse.js +0 -114
  65. package/dist/DBC/OR.js +0 -113
  66. package/dist/DBC/REGEX.js +0 -110
  67. package/dist/DBC/TYPE.js +0 -87
  68. package/dist/DBC/ZOD.js +0 -114
  69. package/dist/DBC.js +0 -336
  70. package/dist/Demo.js +0 -290
  71. package/dist/Test.html +0 -18
  72. package/dist/bundle.js +0 -2064
  73. package/dist/index.html +0 -18
  74. package/jest.config.ts +0 -20
  75. package/xpackage-lock.json +0 -122
package/dist/DBC/OR.js DELETED
@@ -1,113 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining that all elements of an {@link object }s have to fulfill
4
- * one of the given {@link object }s check-methods (**( toCheck : any ) => boolean | string** ).
5
- *
6
- * @remarks
7
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
8
- export class OR extends DBC {
9
- // #region Condition checking.
10
- /**
11
- * Checks the **value** against the given **conditions**
12
- *
13
- * @param conditions The **{ check: (toCheck: any) => boolean | string }**-{@link object }s to check the **value** against.
14
- * @param value Either **value**-{@link Array < any >}, which's elements will be checked, or the value to be
15
- * checked itself.
16
- * @param index If specified with "idxEnd" being undefined, this {@link Number } will be seen as the index of
17
- * the value-{@link Array }'s element to check. If value isn't an {@link Array } this parameter
18
- * will not have any effect.
19
- * With "idxEnd" not undefined this parameter indicates the beginning of the span of elements to
20
- * check within the value-{@link Array }.
21
- * @param idxEnd Indicates the last element's index (including) of the span of value-{@link Array } elements to check.
22
- * Setting this parameter to -1 specifies that all value-{@link Array }'s elements beginning from the
23
- * specified **index** shall be checked.
24
- *
25
- * @returns TRUE if at least one of the provided **conditions** is fulfilled, otherwise a {@link string } containing all **conditions** returned {@link string }s separated by " || ". */
26
- static checkAlgorithm(conditions, value) {
27
- let result = "";
28
- for (let i = 0; i < conditions.length; i++) {
29
- const conditionResult = conditions[i].check(value);
30
- if (typeof conditionResult === "string") {
31
- result += `${conditionResult}${i === conditions.length - 1 ? "" : " or "}`;
32
- }
33
- else {
34
- return true;
35
- }
36
- }
37
- return result;
38
- }
39
- /**
40
- * A parameter-decorator factory using the {@link OR.checkAlgorithm } with either multiple or a single one
41
- * of the **realConditions** to check the tagged parameter-value against with.
42
- * When specifying an **index** and the tagged parameter's **value** is an {@link Array }, the **realConditions** apply to the
43
- * element at the specified **index**.
44
- * If the {@link Array } is too short the currently processed { check: (toCheck: any) => boolean | string } of
45
- * **realConditions** will be verified to TRUE automatically, considering optional parameters.
46
- * If an **index** is specified but the tagged parameter's value isn't an array, the **index** is treated as being undefined.
47
- * If **index** is undefined and the tagged parameter's value is an {@link Array } each element of it will be checked
48
- * against the **realConditions**.
49
- *
50
- * @param realConditions Either one or more **{ check: (toCheck: any) => boolean | string }** to check the tagged parameter-value
51
- * against with.
52
- * @param path See {@link DBC.decPrecondition }.
53
- * @param dbc See {@link DBC.decPrecondition }.
54
- *
55
- * @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of **realConditions** returns one.
56
- * Otherwise TRUE. */
57
- static PRE(conditions, path = undefined, dbc = "WaXCode.DBC") {
58
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
59
- return OR.checkAlgorithm(conditions, value);
60
- }, dbc, path);
61
- }
62
- /**
63
- * A method-decorator factory using the {@link OR.checkAlgorithm } with either multiple or a single one
64
- * of the **realConditions** to check the tagged method's return-value against with.
65
- *
66
- * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
67
- * against with.
68
- * @param path See {@link DBC.decPrecondition }.
69
- * @param dbc See {@link DBC.decPrecondition }.
70
- *
71
- * @returns A {@link string } as soon as one **{ check: (toCheck: any) => boolean | string }** of **realConditions** return one.
72
- * Otherwise TRUE. */
73
- static POST(conditions, path = undefined, dbc = "WaXCode.DBC") {
74
- return DBC.decPostcondition((value, target, propertyKey) => {
75
- return OR.checkAlgorithm(conditions, value);
76
- }, dbc, path);
77
- }
78
- /**
79
- * A field-decorator factory using the {@link OR.checkAlgorithm } with either multiple or a single one
80
- * of the **realConditions** to check the tagged field.
81
- *
82
- * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
83
- * against with.
84
- * @param path See {@link DBC.decInvariant }.
85
- * @param dbc See {@link DBC.decInvariant }.
86
- *
87
- * @returns See {@link DBC.decInvariant }. */
88
- static INVARIANT(conditions, path = undefined, dbc = "WaXCode.DBC") {
89
- return DBC.decInvariant([new OR(conditions)], path, dbc);
90
- }
91
- // #endregion Condition checking.
92
- // #region Referenced Condition checking.
93
- //
94
- // For usage in dynamic scenarios (like global functions).
95
- //
96
- /**
97
- * Invokes the {@link OR.checkAlgorithm } passing the value **toCheck** and {@link OR.conditions }.
98
- *
99
- * @param toCheck See {@link OR.checkAlgorithm }.
100
- *
101
- * @returns See {@link OR.checkAlgorithm}. */
102
- check(toCheck) {
103
- return OR.checkAlgorithm(this.conditions, toCheck);
104
- }
105
- /**
106
- * Creates this {@link OR } by setting the protected property {@link OR.conditions } used by {@link OR.check }.
107
- *
108
- * @param conditions See {@link OR.check }. */
109
- constructor(conditions) {
110
- super();
111
- this.conditions = conditions;
112
- }
113
- }
package/dist/DBC/REGEX.js DELETED
@@ -1,110 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } providing {@link REGEX }-contracts and standard {@link RegExp } for common use cases in {@link REGEX.stdExp }.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class REGEX extends DBC {
8
- // #region Condition checking.
9
- /**
10
- * Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
11
- *
12
- * @param toCheck The value that has comply to the {@link RegExp } **expression** for this {@link DBC } to be fulfilled.
13
- * @param expression The {@link RegExp } the one **toCheck** has comply to in order for this {@link DBC } to be
14
- * fulfilled.
15
- *
16
- * @returns TRUE if the value **toCheck** complies with the {@link RegExp } **expression**, otherwise FALSE. */
17
- static checkAlgorithm(toCheck, expression) {
18
- if (!expression.test(toCheck)) {
19
- return `Value has to comply to regular expression "${expression}"`;
20
- }
21
- return true;
22
- }
23
- /**
24
- * A parameter-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
25
- * by the tagged parameter.
26
- *
27
- * @param expression See {@link REGEX.checkAlgorithm }.
28
- * @param path See {@link DBC.decPrecondition }.
29
- * @param dbc See {@link DBC.decPrecondition }.
30
- *
31
- * @returns See {@link DBC.decPrecondition }. */
32
- static PRE(expression, path = undefined, dbc = "WaXCode.DBC") {
33
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
34
- return REGEX.checkAlgorithm(value, expression);
35
- }, dbc, path);
36
- }
37
- /**
38
- * A method-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
39
- * by the tagged method's returnvalue.
40
- *
41
- * @param expression See {@link REGEX.checkAlgorithm }.
42
- * @param path See {@link DBC.Postcondition }.
43
- * @param dbc See {@link DBC.decPostcondition }.
44
- *
45
- * @returns See {@link DBC.decPostcondition }. */
46
- static POST(expression, path = undefined, dbc = "WaXCode.DBC") {
47
- return DBC.decPostcondition((value, target, propertyKey) => {
48
- return REGEX.checkAlgorithm(value, expression);
49
- }, dbc, path);
50
- }
51
- /**
52
- * A field-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
53
- * by the tagged field.
54
- *
55
- * @param expression See {@link REGEX.checkAlgorithm }.
56
- * @param path See {@link DBC.decInvariant }.
57
- * @param dbc See {@link DBC.decInvariant }.
58
- *
59
- * @returns See {@link DBC.decInvariant }. */
60
- static INVARIANT(expression, path = undefined, dbc = "WaXCode.DBC") {
61
- return DBC.decInvariant([new REGEX(expression)], path, dbc);
62
- }
63
- // #endregion Condition checking.
64
- // #region Referenced Condition checking.
65
- //
66
- // For usage in dynamic scenarios (like with AE-DBC).
67
- //
68
- /**
69
- * Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.equivalent }.
70
- *
71
- * @param toCheck See {@link REGEX.checkAlgorithm }.
72
- *
73
- * @returns See {@link EQ.checkAlgorithm}. */
74
- check(toCheck) {
75
- return REGEX.checkAlgorithm(toCheck, this.expression);
76
- }
77
- /**
78
- * Creates this {@link REGEX } by setting the protected property {@link REGEX.expression } used by {@link REGEX.check }.
79
- *
80
- * @param expression See {@link REGEX.check }. */
81
- constructor(expression) {
82
- super();
83
- this.expression = expression;
84
- }
85
- // #endregion Referenced Condition checking.
86
- // #region In-Method checking.
87
- /**
88
- * Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.expression }.
89
- *
90
- * @param toCheck See {@link REGEX.checkAlgorithm}.
91
- * @param expression See {@link REGEX.checkAlgorithm}.
92
- */
93
- static check(toCheck, expression) {
94
- const checkResult = REGEX.checkAlgorithm(toCheck, expression);
95
- if (typeof checkResult === "string") {
96
- throw new DBC.Infringement(checkResult);
97
- }
98
- }
99
- }
100
- /** Stores often used {@link RegExp }s. */
101
- REGEX.stdExp = {
102
- htmlAttributeName: /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/,
103
- eMail: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i,
104
- property: /^[$_A-Za-z][$_A-Za-z0-9]*$/,
105
- url: /^(?:(?:http:|https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:localhost|(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,})(?::\d{2,5})?(?:\/(?:[\w\-\.]*\/)*[\w\-\.]+(?:\?\S*)?(?:#\S*)?)?$/i,
106
- keyPath: /^([a-zA-Z_$][a-zA-Z0-9_$]*\.)*[a-zA-Z_$][a-zA-Z0-9_$]*$/,
107
- date: /^\d{1,4}[.\/-]\d{1,2}[.\/-]\d{1,4}$/i,
108
- dateFormat: /^((D{1,2}[./-]M{1,2}[./-]Y{1,4})|(M{1,2}[./-]D{1,2}[./-]Y{1,4})|Y{1,4}[./-]D{1,2}[./-]M{1,2}|(Y{1,4}[./-]M{1,2}[./-]D{1,2}))$/i,
109
- cssSelector: /^(?:\*|#[\w-]+|\.[\w-]+|(?:[\w-]+|\*)(?::(?:[\w-]+(?:\([\w-]+\))?)+)?(?:\[(?:[\w-]+(?:(?:=|~=|\|=|\*=|\$=|\^=)\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*)?)?\])+|\[\s*[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*\])(?:,\s*(?:\*|#[\w-]+|\.[\w-]+|(?:[\w-]+|\*)(?::(?:[\w-]+(?:\([\w-]+\))?)+)?(?:\[(?:[\w-]+(?:(?:=|~=|\|=|\*=|\$=|\^=)\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*)?)?\])+|\[\s*[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[\w-]+)\s*\]))*$/,
110
- };
package/dist/DBC/TYPE.js DELETED
@@ -1,87 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining that an {@link object }s gotta be of certain {@link TYPE.type }.
4
- *
5
- * @remarks
6
- * Author: Salvatore Callari (Callari@WaXCode.net) / 2025
7
- * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
8
- export class TYPE extends DBC {
9
- /**
10
- * Checks if the value **toCheck** is of the **type** specified.
11
- *
12
- * @param toCheck The {@link Object } which's **type** to check.
13
- * @param type The type the {@link object} **toCheck** has to be of.
14
- *
15
- * @returns TRUE if the value **toCheck** is of the specified **type**, otherwise FALSE. */
16
- // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic type checking of also UNDEFINED.
17
- static checkAlgorithm(toCheck, type) {
18
- // biome-ignore lint/suspicious/useValidTypeof: Necessary
19
- if (typeof toCheck !== type) {
20
- return `Value has to to be of type "${type}" but is of type "${typeof toCheck}"`;
21
- }
22
- return true;
23
- }
24
- /**
25
- * A parameter-decorator factory using the {@link TYPE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
26
- * by the tagged parameter.
27
- *
28
- * @param type See {@link TYPE.checkAlgorithm }.
29
- * @param path See {@link DBC.decPrecondition }.
30
- * @param dbc See {@link DBC.decPrecondition }.
31
- *
32
- * @returns See {@link DBC.decPrecondition }. */
33
- static PRE(type, path = undefined, dbc = "WaXCode.DBC") {
34
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
35
- return TYPE.checkAlgorithm(value, type);
36
- }, dbc, path);
37
- }
38
- /**
39
- * A method-decorator factory using the {@link TYPE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
40
- * by the tagged method's returnvalue.
41
- *
42
- * @param type See {@link TYPE.checkAlgorithm }.
43
- * @param path See {@link DBC.Postcondition }.
44
- * @param dbc See {@link DBC.decPostcondition }.
45
- *
46
- * @returns See {@link DBC.decPostcondition }. */
47
- static POST(type, path = undefined, dbc = "WaXCode.DBC") {
48
- return DBC.decPostcondition((value, target, propertyKey) => {
49
- return TYPE.checkAlgorithm(value, type);
50
- }, dbc, path);
51
- }
52
- /**
53
- * A field-decorator factory using the {@link TYPE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
54
- * by the tagged field.
55
- *
56
- * @param type See {@link TYPE.checkAlgorithm }.
57
- * @param path See {@link DBC.decInvariant }.
58
- * @param dbc See {@link DBC.decInvariant }.
59
- *
60
- * @returns See {@link DBC.decInvariant }. */
61
- static INVARIANT(type, path = undefined, dbc = "WaXCode.DBC") {
62
- return DBC.decInvariant([new TYPE(type)], path, dbc);
63
- }
64
- // #endregion Condition checking.
65
- // #region Referenced Condition checking.
66
- //
67
- // For usage in dynamic scenarios (like with AE-DBC).
68
- //
69
- /**
70
- * Invokes the {@link TYPE.checkAlgorithm } passing the value **toCheck** and the {@link TYPE.type } .
71
- *
72
- * @param toCheck See {@link TYPE.checkAlgorithm }.
73
- *
74
- * @returns See {@link TYPE.checkAlgorithm}. */
75
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
76
- check(toCheck) {
77
- return TYPE.checkAlgorithm(toCheck, this.type);
78
- }
79
- /**
80
- * Creates this {@link TYPE } by setting the protected property {@link TYPE.type } used by {@link TYPE.check }.
81
- *
82
- * @param type See {@link TYPE.check }. */
83
- constructor(type) {
84
- super();
85
- this.type = type;
86
- }
87
- }
package/dist/DBC/ZOD.js DELETED
@@ -1,114 +0,0 @@
1
- import { DBC } from "../DBC";
2
- import { z } from 'zod';
3
- /**
4
- * A {@link DBC } defining that the an {@link object }s gotta be an instance of a certain {@link ZOD.schema }.
5
- *
6
- * @remarks
7
- * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
8
- export class ZOD extends DBC {
9
- /**
10
- * Checks if the value **toCheck** complies to the specified {@link z.ZodType }.
11
- *
12
- * @param toCheck The value that has to comply to the specified **schema** in order for this {@link DBC }
13
- * @param schema The {@link z.ZodType } the {@link object } **toCheck** has comply to in order for this {@link DBC } to be
14
- * fulfilled.
15
- *
16
- * @returns TRUE if the value **toCheck** complies to the specified **schema**, otherwise FALSE. */
17
- // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
18
- static checkAlgorithm(toCheck, schema) {
19
- if (!schema.safeParse(toCheck).success) {
20
- console.log(z.toJSONSchema(schema));
21
- return `Value has to correspond to "${JSON.stringify(z.toJSONSchema(schema).properties)}" but is constituted as "${JSON.stringify(toCheck)}"`;
22
- }
23
- return true;
24
- }
25
- /**
26
- * A parameter-decorator factory using the {@link ZOD.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
27
- * by the tagged parameter.
28
- *
29
- * @param schema See {@link ZOD.checkAlgorithm }.
30
- * @param path See {@link DBC.decPrecondition }.
31
- * @param dbc See {@link DBC.decPrecondition }.
32
- *
33
- * @returns See {@link DBC.decPrecondition }. */
34
- static PRE(
35
- // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
36
- schema, path = undefined, dbc = "WaXCode.DBC") {
37
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
38
- return ZOD.checkAlgorithm(value, schema);
39
- }, dbc, path);
40
- }
41
- /**
42
- * A method-decorator factory using the {@link ZOD.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
43
- * by the tagged method's returnvalue.
44
- *
45
- * @param schema See {@link ZOD.checkAlgorithm }.
46
- * @param path See {@link DBC.Postcondition }.
47
- * @param dbc See {@link DBC.decPostcondition }.
48
- *
49
- * @returns See {@link DBC.decPostcondition }. */
50
- static POST(
51
- // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
52
- schema, path = undefined, dbc = "WaXCode.DBC") {
53
- return DBC.decPostcondition((value, target, propertyKey) => {
54
- return ZOD.checkAlgorithm(value, schema);
55
- }, dbc, path);
56
- }
57
- /**
58
- * A field-decorator factory using the {@link ZOD.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
59
- * by the tagged method's returnvalue.
60
- *
61
- * @param schema See {@link ZOD.checkAlgorithm }.
62
- * @param path See {@link DBC.decInvariant }.
63
- * @param dbc See {@link DBC.decInvariant }.
64
- *
65
- * @returns See {@link DBC.decInvariant }. */
66
- static INVARIANT(
67
- // biome-ignore lint/suspicious/noExplicitAny: In order to perform an "instanceof" check.
68
- schema, path = undefined, dbc = "WaXCode.DBC") {
69
- return DBC.decInvariant([new ZOD(schema)], path, dbc);
70
- }
71
- // #endregion Condition checking.
72
- // #region Referenced Condition checking.
73
- //
74
- // For usage in dynamic scenarios (like with AE-DBC).
75
- //
76
- /**
77
- * Invokes the {@link ZOD.checkAlgorithm } passing the value **toCheck** and the {@link ZOD.schema } .
78
- *
79
- * @param toCheck See {@link ZOD.checkAlgorithm }.
80
- *
81
- * @returns See {@link ZOD.checkAlgorithm}. */
82
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
83
- check(toCheck) {
84
- return ZOD.checkAlgorithm(toCheck, this.schema);
85
- }
86
- /**
87
- * Invokes the {@link ZOD.checkAlgorithm } passing the value **toCheck** and the {@link ZOD.schema } .
88
- *
89
- * @param toCheck See {@link ZOD.checkAlgorithm }.
90
- * @param schema See {@link ZOD.checkAlgorithm }.
91
- * @param id A {@link string } identifying this {@link ZOD } via the {@link DBC.Infringement }-Message.
92
- *
93
- * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link ZOD }.
94
- *
95
- * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }. */
96
- static tsCheck(toCheck, schema, id = undefined) {
97
- const result = ZOD.checkAlgorithm(toCheck, schema);
98
- if (result === true) {
99
- return toCheck;
100
- }
101
- else {
102
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result}`);
103
- }
104
- }
105
- /**
106
- * Creates this {@link ZOD } by setting the protected property {@link ZOD.schema } used by {@link ZOD.check }.
107
- *
108
- * @param schema See {@link ZOD.check }. */
109
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
110
- constructor(schema) {
111
- super();
112
- this.schema = schema;
113
- }
114
- }