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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } demanding that a {@link string } is {@link JSON.parse}able.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
+
export declare class JSON_Parse extends DBC {
|
|
8
|
+
receptor: ((json: object) => void) | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Tries to {@link JSON.parse } the {@link string } **toCheck** invoking the **receptor** with the result, if so.
|
|
11
|
+
*
|
|
12
|
+
* @param toCheck The {@link string } to be {@link JSON.parse }d.
|
|
13
|
+
* @param receptor The **( json : object ) => void** to receive the {@link JSON.parse }d {@link string } **toCheck**.
|
|
14
|
+
* check needs to have.
|
|
15
|
+
*
|
|
16
|
+
* @returns TRUE if the value **toCheck** is a valid JSON, otherwise a {@link string } to report the infringement. */
|
|
17
|
+
static checkAlgorithm(toCheck: string, receptor: (json: object) => void): boolean | string;
|
|
18
|
+
/**
|
|
19
|
+
* A parameter-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
20
|
+
* by the tagged parameter.
|
|
21
|
+
*
|
|
22
|
+
* @param receptor See {@link JSON.checkAlgorithm }.
|
|
23
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
24
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
25
|
+
*
|
|
26
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
27
|
+
static PRE(receptor: (json: object) => void, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
28
|
+
/**
|
|
29
|
+
* A method-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
30
|
+
* by the tagged method's returnvalue.
|
|
31
|
+
*
|
|
32
|
+
* @param expression See {@link JSON.checkAlgorithm }.
|
|
33
|
+
* @param path See {@link DBC.Postcondition }.
|
|
34
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
35
|
+
*
|
|
36
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
37
|
+
static POST(receptor: (json: object) => void, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
38
|
+
/**
|
|
39
|
+
* A field-decorator factory using the {@link JSON_Parse.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
40
|
+
* by the tagged field.
|
|
41
|
+
*
|
|
42
|
+
* @param expression See {@link JSON.checkAlgorithm }.
|
|
43
|
+
* @param path See {@link DBC.decInvariant }.
|
|
44
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
45
|
+
*
|
|
46
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
47
|
+
static INVARIANT(receptor: (json: object) => void, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck** and {@link JSON_Parse.receptor }.
|
|
50
|
+
*
|
|
51
|
+
* @param toCheck See {@link JSON_Parse.checkAlgorithm }.
|
|
52
|
+
*
|
|
53
|
+
* @returns See {@link JSON_Parse.checkAlgorithm}. */
|
|
54
|
+
check(toCheck: any): string | boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Creates this {@link JSON_Parse } by setting the protected property {@link JSON_Parse.necessaryProperties } and {@link checkElements } used by {@link JSON_Parse.check }.
|
|
57
|
+
*
|
|
58
|
+
* @param necessaryProperties See {@link JSON_Parse.check }.
|
|
59
|
+
* @param checkElements See {@link JSON_Parse.check }. */
|
|
60
|
+
constructor(receptor?: ((json: object) => void) | undefined);
|
|
61
|
+
/**
|
|
62
|
+
* Invokes the {@link JSON_Parse.checkAlgorithm } passing the value **toCheck**, {@link JSON_Parse.necessaryProperties } and {@link JSON_Parse.checkElements }.
|
|
63
|
+
*
|
|
64
|
+
* @param toCheck See {@link JSON_Parse.checkAlgorithm} }.
|
|
65
|
+
* @param necessaryProperties See {@link JSON_Parse.checkAlgorithm} }.
|
|
66
|
+
* @param checkElements See {@link JSON_Parse.checkAlgorithm} }.
|
|
67
|
+
*/
|
|
68
|
+
static check(toCheck: any, receptor: (json: object) => void): void;
|
|
69
|
+
}
|
package/dist/DBC/OR.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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 declare class OR extends DBC {
|
|
9
|
+
protected conditions: Array<{
|
|
10
|
+
check: (toCheck: unknown | undefined | null) => boolean | string;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Checks the **value** against the given **conditions**
|
|
14
|
+
*
|
|
15
|
+
* @param conditions The **{ check: (toCheck: any) => boolean | string }**-{@link object }s to check the **value** against.
|
|
16
|
+
* @param value Either **value**-{@link Array < any >}, which's elements will be checked, or the value to be
|
|
17
|
+
* checked itself.
|
|
18
|
+
* @param index If specified with "idxEnd" being undefined, this {@link Number } will be seen as the index of
|
|
19
|
+
* the value-{@link Array }'s element to check. If value isn't an {@link Array } this parameter
|
|
20
|
+
* will not have any effect.
|
|
21
|
+
* With "idxEnd" not undefined this parameter indicates the beginning of the span of elements to
|
|
22
|
+
* check within the value-{@link Array }.
|
|
23
|
+
* @param idxEnd Indicates the last element's index (including) of the span of value-{@link Array } elements to check.
|
|
24
|
+
* Setting this parameter to -1 specifies that all value-{@link Array }'s elements beginning from the
|
|
25
|
+
* specified **index** shall be checked.
|
|
26
|
+
*
|
|
27
|
+
* @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 " || ". */
|
|
28
|
+
static checkAlgorithm(conditions: Array<{
|
|
29
|
+
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
30
|
+
}>, value: unknown | null | undefined): boolean | string;
|
|
31
|
+
/**
|
|
32
|
+
* A parameter-decorator factory using the {@link OR.checkAlgorithm } with either multiple or a single one
|
|
33
|
+
* of the **realConditions** to check the tagged parameter-value against with.
|
|
34
|
+
* When specifying an **index** and the tagged parameter's **value** is an {@link Array }, the **realConditions** apply to the
|
|
35
|
+
* element at the specified **index**.
|
|
36
|
+
* If the {@link Array } is too short the currently processed { check: (toCheck: any) => boolean | string } of
|
|
37
|
+
* **realConditions** will be verified to TRUE automatically, considering optional parameters.
|
|
38
|
+
* If an **index** is specified but the tagged parameter's value isn't an array, the **index** is treated as being undefined.
|
|
39
|
+
* If **index** is undefined and the tagged parameter's value is an {@link Array } each element of it will be checked
|
|
40
|
+
* against the **realConditions**.
|
|
41
|
+
*
|
|
42
|
+
* @param realConditions Either one or more **{ check: (toCheck: any) => boolean | string }** to check the tagged parameter-value
|
|
43
|
+
* against with.
|
|
44
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
45
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
46
|
+
*
|
|
47
|
+
* @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of **realConditions** returns one.
|
|
48
|
+
* Otherwise TRUE. */
|
|
49
|
+
static PRE(conditions: Array<{
|
|
50
|
+
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
51
|
+
}>, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
52
|
+
/**
|
|
53
|
+
* A method-decorator factory using the {@link OR.checkAlgorithm } with either multiple or a single one
|
|
54
|
+
* of the **realConditions** to check the tagged method's return-value against with.
|
|
55
|
+
*
|
|
56
|
+
* @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
|
|
57
|
+
* against with.
|
|
58
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
59
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
60
|
+
*
|
|
61
|
+
* @returns A {@link string } as soon as one **{ check: (toCheck: any) => boolean | string }** of **realConditions** return one.
|
|
62
|
+
* Otherwise TRUE. */
|
|
63
|
+
static POST(conditions: Array<{
|
|
64
|
+
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
65
|
+
}>, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
66
|
+
/**
|
|
67
|
+
* A field-decorator factory using the {@link OR.checkAlgorithm } with either multiple or a single one
|
|
68
|
+
* of the **realConditions** to check the tagged field.
|
|
69
|
+
*
|
|
70
|
+
* @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
|
|
71
|
+
* against with.
|
|
72
|
+
* @param path See {@link DBC.decInvariant }.
|
|
73
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
74
|
+
*
|
|
75
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
76
|
+
static INVARIANT(conditions: Array<{
|
|
77
|
+
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
78
|
+
}>, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Invokes the {@link OR.checkAlgorithm } passing the value **toCheck** and {@link OR.conditions }.
|
|
81
|
+
*
|
|
82
|
+
* @param toCheck See {@link OR.checkAlgorithm }.
|
|
83
|
+
*
|
|
84
|
+
* @returns See {@link OR.checkAlgorithm}. */
|
|
85
|
+
check(toCheck: unknown | null | undefined): string | boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Invokes the {@link OR.checkAlgorithm } passing the value **toCheck** and the {@link OR.type } .
|
|
88
|
+
*
|
|
89
|
+
* @param toCheck See {@link OR.checkAlgorithm }.
|
|
90
|
+
*
|
|
91
|
+
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link OR }.
|
|
92
|
+
*
|
|
93
|
+
* @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link OR }.*/
|
|
94
|
+
static tsCheck<CANDIDATE>(toCheck: unknown | undefined | null, conditions: Array<{
|
|
95
|
+
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
96
|
+
}>, hint?: string, id?: string | undefined): CANDIDATE;
|
|
97
|
+
/**
|
|
98
|
+
* Creates this {@link OR } by setting the protected property {@link OR.conditions } used by {@link OR.check }.
|
|
99
|
+
*
|
|
100
|
+
* @param conditions See {@link OR.check }. */
|
|
101
|
+
constructor(conditions: Array<{
|
|
102
|
+
check: (toCheck: unknown | undefined | null) => boolean | string;
|
|
103
|
+
}>);
|
|
104
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 declare class REGEX extends DBC {
|
|
8
|
+
protected expression: RegExp;
|
|
9
|
+
/** Stores often used {@link RegExp }s. Patterns are compiled lazily on first access. */
|
|
10
|
+
private static _stdExp;
|
|
11
|
+
static get stdExp(): {
|
|
12
|
+
htmlAttributeName: RegExp;
|
|
13
|
+
eMail: RegExp;
|
|
14
|
+
property: RegExp;
|
|
15
|
+
url: RegExp;
|
|
16
|
+
keyPath: RegExp;
|
|
17
|
+
date: RegExp;
|
|
18
|
+
dateFormat: RegExp;
|
|
19
|
+
cssSelector: RegExp;
|
|
20
|
+
boolean: RegExp;
|
|
21
|
+
colorCodeHEX: RegExp;
|
|
22
|
+
simpleHotkey: RegExp;
|
|
23
|
+
bcp47: RegExp;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the value **toCheck** is complies to the {@link RegExp } **expression**.
|
|
27
|
+
*
|
|
28
|
+
* @param toCheck The value that has comply to the {@link RegExp } **expression** for this {@link DBC } to be fulfilled.
|
|
29
|
+
* @param expression The {@link RegExp } the one **toCheck** has comply to in order for this {@link DBC } to be
|
|
30
|
+
* fulfilled.
|
|
31
|
+
*
|
|
32
|
+
* @returns TRUE if the value **toCheck** complies with the {@link RegExp } **expression**, otherwise FALSE. */
|
|
33
|
+
static checkAlgorithm(toCheck: unknown | null | undefined, expression: RegExp): boolean | string;
|
|
34
|
+
/**
|
|
35
|
+
* A parameter-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
36
|
+
* by the tagged parameter.
|
|
37
|
+
*
|
|
38
|
+
* @param expression See {@link REGEX.checkAlgorithm }.
|
|
39
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
40
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
41
|
+
*
|
|
42
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
43
|
+
static PRE(expression: RegExp, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
44
|
+
/**
|
|
45
|
+
* A method-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
46
|
+
* by the tagged method's returnvalue.
|
|
47
|
+
*
|
|
48
|
+
* @param expression See {@link REGEX.checkAlgorithm }.
|
|
49
|
+
* @param path See {@link DBC.Postcondition }.
|
|
50
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
51
|
+
* @param hint See {@link DBC.decPostcondition }.
|
|
52
|
+
*
|
|
53
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
54
|
+
static POST(expression: RegExp, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
55
|
+
/**
|
|
56
|
+
* A field-decorator factory using the {@link REGEX.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
57
|
+
* by the tagged field.
|
|
58
|
+
*
|
|
59
|
+
* @param expression See {@link REGEX.checkAlgorithm }.
|
|
60
|
+
* @param path See {@link DBC.decInvariant }.
|
|
61
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
62
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
63
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
64
|
+
static INVARIANT(expression: RegExp, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.equivalent }.
|
|
67
|
+
*
|
|
68
|
+
* @param toCheck See {@link REGEX.checkAlgorithm }.
|
|
69
|
+
*
|
|
70
|
+
* @returns See {@link EQ.checkAlgorithm}. */
|
|
71
|
+
check(toCheck: unknown | null | undefined): string | boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Type-safe check that validates a value against a regular expression and returns it as the specified type.
|
|
74
|
+
*
|
|
75
|
+
* @param toCheck The value to check against the regular expression.
|
|
76
|
+
* @param expression The regular expression to validate against.
|
|
77
|
+
* @param hint Optional hint message to include in the error if validation fails.
|
|
78
|
+
* @param id Optional identifier to include in the error message.
|
|
79
|
+
*
|
|
80
|
+
* @returns The validated value cast to the CANDIDATE type.
|
|
81
|
+
*
|
|
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;
|
|
84
|
+
/**
|
|
85
|
+
* Creates this {@link REGEX } by setting the protected property {@link REGEX.expression } used by {@link REGEX.check }.
|
|
86
|
+
*
|
|
87
|
+
* @param expression See {@link REGEX.check }. */
|
|
88
|
+
constructor(expression: RegExp);
|
|
89
|
+
/**
|
|
90
|
+
* Invokes the {@link REGEX.checkAlgorithm } passing the value **toCheck** and {@link REGEX.expression }.
|
|
91
|
+
*
|
|
92
|
+
* @param toCheck See {@link REGEX.checkAlgorithm}.
|
|
93
|
+
* @param expression See {@link REGEX.checkAlgorithm}.
|
|
94
|
+
*/
|
|
95
|
+
static check(toCheck: unknown | null | undefined, expression: RegExp): void;
|
|
96
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 declare class TYPE extends DBC {
|
|
9
|
+
protected type: string;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the value **toCheck** is of the **type** specified.
|
|
12
|
+
*
|
|
13
|
+
* @param toCheck The {@link Object } which's **type** to check.
|
|
14
|
+
* @param type The type the {@link object} **toCheck** has to be of. Can be a single type or multiple types separated by "|".
|
|
15
|
+
*
|
|
16
|
+
* @returns TRUE if the value **toCheck** is of the specified **type**, otherwise FALSE. */
|
|
17
|
+
static checkAlgorithm(toCheck: any, type: string): boolean | string;
|
|
18
|
+
/**
|
|
19
|
+
* A parameter-decorator factory using the {@link TYPE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
20
|
+
* by the tagged parameter.
|
|
21
|
+
*
|
|
22
|
+
* @param type See {@link TYPE.checkAlgorithm }.
|
|
23
|
+
* @param path A ::-separated list of dotted paths to check. Each path points to a property within the parameter value.
|
|
24
|
+
* Undefined properties are skipped. See {@link DBC.decPrecondition }.
|
|
25
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
26
|
+
*
|
|
27
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
28
|
+
static PRE(type: string, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
29
|
+
/**
|
|
30
|
+
* A method-decorator factory using the {@link TYPE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
31
|
+
* by the tagged method's returnvalue.
|
|
32
|
+
*
|
|
33
|
+
* @param type See {@link TYPE.checkAlgorithm }.
|
|
34
|
+
* @param path A ::-separated list of dotted paths to check. Each path points to a property within the parameter value.
|
|
35
|
+
* Undefined properties are skipped. See {@link DBC.decPrecondition }.
|
|
36
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
37
|
+
*
|
|
38
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
39
|
+
static POST(type: string, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
40
|
+
/**
|
|
41
|
+
* A field-decorator factory using the {@link TYPE.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
42
|
+
* by the tagged field.
|
|
43
|
+
*
|
|
44
|
+
* @param type See {@link TYPE.checkAlgorithm }.
|
|
45
|
+
* @param path A ::-separated list of dotted paths to check. Each path points to a property within the parameter value.
|
|
46
|
+
* Undefined properties are skipped. See {@link DBC.decPrecondition }.
|
|
47
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
48
|
+
*
|
|
49
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
50
|
+
static INVARIANT(type: string, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Invokes the {@link TYPE.checkAlgorithm } passing the value **toCheck** and the {@link TYPE.type } .
|
|
53
|
+
*
|
|
54
|
+
* @param toCheck See {@link TYPE.checkAlgorithm }.
|
|
55
|
+
*
|
|
56
|
+
* @returns See {@link TYPE.checkAlgorithm}. */
|
|
57
|
+
check(toCheck: any): string | boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Invokes the {@link TYPE.checkAlgorithm } passing the value **toCheck** and the {@link TYPE.type } .
|
|
60
|
+
*
|
|
61
|
+
* @param toCheck See {@link TYPE.checkAlgorithm }.
|
|
62
|
+
* @param type See {@link TYPE.checkAlgorithm }.
|
|
63
|
+
* @param hint An optional {@link string } providing extra information in case of an infringement.
|
|
64
|
+
* @param id A {@link string } identifying this {@link TYPE } via the {@link DBC.Infringement }-Message.
|
|
65
|
+
*
|
|
66
|
+
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link TYPE }.
|
|
67
|
+
*
|
|
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;
|
|
70
|
+
/**
|
|
71
|
+
* Creates this {@link TYPE } by setting the protected property {@link TYPE.type } used by {@link TYPE.check }.
|
|
72
|
+
*
|
|
73
|
+
* @param type See {@link TYPE.check }. */
|
|
74
|
+
constructor(type: string);
|
|
75
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that an {@link object }s must be **undefined**.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
+
export declare class UNDEFINED extends DBC {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the value **toCheck** is undefined.
|
|
10
|
+
*
|
|
11
|
+
* @param toCheck The {@link Object } to check.
|
|
12
|
+
*
|
|
13
|
+
* @returns TRUE if the value **toCheck** is of the specified **type**, otherwise FALSE. */
|
|
14
|
+
static checkAlgorithm(toCheck: any): boolean | string;
|
|
15
|
+
/**
|
|
16
|
+
* A parameter-decorator factory using the {@link UNDEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
17
|
+
* by the tagged parameter.
|
|
18
|
+
*
|
|
19
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
20
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
21
|
+
* @param hint 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, parameterIndex: number) => void;
|
|
25
|
+
/**
|
|
26
|
+
* A method-decorator factory using the {@link UNDEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
27
|
+
* by the tagged method's returnvalue.
|
|
28
|
+
*
|
|
29
|
+
* @param path See {@link DBC.Postcondition }.
|
|
30
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
31
|
+
* @param hint 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 UNDEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
37
|
+
* by the tagged field.
|
|
38
|
+
*
|
|
39
|
+
* @param path See {@link DBC.decInvariant }.
|
|
40
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
41
|
+
* @param hint See {@link DBC.decInvariant }.
|
|
42
|
+
*
|
|
43
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
44
|
+
static INVARIANT(type: string, path?: string | undefined, hint?: string | undefined, dbc?: string | undefined): (target: unknown, propertyKey: string | symbol) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Invokes the {@link UNDEFINED.checkAlgorithm } passing the value **toCheck** and the {@link UNDEFINED.type } .
|
|
47
|
+
*
|
|
48
|
+
* @param toCheck See {@link UNDEFINED.checkAlgorithm }.
|
|
49
|
+
*
|
|
50
|
+
* @returns See {@link UNDEFINED.checkAlgorithm}. */
|
|
51
|
+
check(toCheck: any): string | boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Invokes the {@link UNDEFINED.checkAlgorithm } passing the value **toCheck** and the {@link UNDEFINED.type } .
|
|
54
|
+
*
|
|
55
|
+
* @param toCheck See {@link UNDEFINED.checkAlgorithm }.
|
|
56
|
+
* @param id A {@link string } identifying this {@link INSTANCE } via the {@link DBC.Infringement }-Message.
|
|
57
|
+
*
|
|
58
|
+
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link UNDEFINED }.
|
|
59
|
+
*
|
|
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;
|
|
62
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { DBC } from "../DBC";
|
|
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 declare class ZOD extends DBC {
|
|
9
|
+
protected schema: z.ZodType;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the value **toCheck** complies to the specified {@link z.ZodType }.
|
|
12
|
+
*
|
|
13
|
+
* @param toCheck The value that has to comply to the specified **schema** in order for this {@link DBC }
|
|
14
|
+
* @param schema The {@link z.ZodType } the {@link object } **toCheck** has comply to in order for this {@link DBC } to be
|
|
15
|
+
* fulfilled.
|
|
16
|
+
*
|
|
17
|
+
* @returns TRUE if the value **toCheck** complies to the specified **schema**, otherwise FALSE. */
|
|
18
|
+
static checkAlgorithm(toCheck: any, schema: z.ZodType): boolean | string;
|
|
19
|
+
/**
|
|
20
|
+
* A parameter-decorator factory using the {@link ZOD.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
21
|
+
* by the tagged parameter.
|
|
22
|
+
*
|
|
23
|
+
* @param schema See {@link ZOD.checkAlgorithm }.
|
|
24
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
25
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
26
|
+
*
|
|
27
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
28
|
+
static PRE(schema: z.ZodType, path?: string | undefined, dbc?: string): (target: object, methodName: string | symbol, parameterIndex: number) => void;
|
|
29
|
+
/**
|
|
30
|
+
* A method-decorator factory using the {@link ZOD.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
31
|
+
* by the tagged method's returnvalue.
|
|
32
|
+
*
|
|
33
|
+
* @param schema See {@link ZOD.checkAlgorithm }.
|
|
34
|
+
* @param path See {@link DBC.Postcondition }.
|
|
35
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
36
|
+
*
|
|
37
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
38
|
+
static POST(schema: z.ZodType, path?: string | undefined, dbc?: string): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
39
|
+
/**
|
|
40
|
+
* A field-decorator factory using the {@link ZOD.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
41
|
+
* by the tagged method's returnvalue.
|
|
42
|
+
*
|
|
43
|
+
* @param schema See {@link ZOD.checkAlgorithm }.
|
|
44
|
+
* @param path See {@link DBC.decInvariant }.
|
|
45
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
46
|
+
*
|
|
47
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
48
|
+
static INVARIANT(schema: z.ZodType, path?: string | undefined, dbc?: string): (target: unknown, propertyKey: string | symbol) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Invokes the {@link ZOD.checkAlgorithm } passing the value **toCheck** and the {@link ZOD.schema } .
|
|
51
|
+
*
|
|
52
|
+
* @param toCheck See {@link ZOD.checkAlgorithm }.
|
|
53
|
+
*
|
|
54
|
+
* @returns See {@link ZOD.checkAlgorithm}. */
|
|
55
|
+
check(toCheck: any): string | boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Invokes the {@link ZOD.checkAlgorithm } passing the value **toCheck** and the {@link ZOD.schema } .
|
|
58
|
+
*
|
|
59
|
+
* @param toCheck See {@link ZOD.checkAlgorithm }.
|
|
60
|
+
* @param schema See {@link ZOD.checkAlgorithm }.
|
|
61
|
+
* @param id A {@link string } identifying this {@link ZOD } via the {@link DBC.Infringement }-Message.
|
|
62
|
+
*
|
|
63
|
+
* @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link ZOD }.
|
|
64
|
+
*
|
|
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;
|
|
67
|
+
/**
|
|
68
|
+
* Creates this {@link ZOD } by setting the protected property {@link ZOD.schema } used by {@link ZOD.check }.
|
|
69
|
+
*
|
|
70
|
+
* @param schema See {@link ZOD.check }. */
|
|
71
|
+
constructor(schema: z.ZodType);
|
|
72
|
+
}
|