xdbc 1.0.100 → 1.0.102
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/package.json +1 -1
- package/src/DBC/DEFINED.ts +17 -2
package/package.json
CHANGED
package/src/DBC/DEFINED.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { DBC } from "../DBC";
|
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
|
|
7
|
-
export class DEFINED extends DBC {
|
|
7
|
+
export class DEFINED < CANDIDATE = any > extends DBC {
|
|
8
8
|
/**
|
|
9
9
|
* Checks if the value **toCheck** is null or undefined.
|
|
10
10
|
*
|
|
@@ -15,7 +15,7 @@ export class DEFINED extends DBC {
|
|
|
15
15
|
public static checkAlgorithm(toCheck: any ): boolean | string {
|
|
16
16
|
// biome-ignore lint/suspicious/useValidTypeof: Necessary
|
|
17
17
|
if ( toCheck === undefined || toCheck === null ) {
|
|
18
|
-
return `Value may not be UNDEFINED or NULL`;
|
|
18
|
+
return `Value may not be UNDEFINED or NULL but it is ${ toCheck === undefined ? "UNDEFINED" : "NULL"}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
return true;
|
|
@@ -107,6 +107,21 @@ export class DEFINED extends DBC {
|
|
|
107
107
|
public check(toCheck: any) {
|
|
108
108
|
return DEFINED.checkAlgorithm(toCheck);
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param toCheck
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
public tsCheck( toCheck : CANDIDATE | undefined | null ) : CANDIDATE {
|
|
116
|
+
const result = DEFINED.checkAlgorithm(toCheck );
|
|
117
|
+
|
|
118
|
+
if( result ) {
|
|
119
|
+
return toCheck as CANDIDATE ;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw new DBC.Infringement( result as string );
|
|
123
|
+
}
|
|
124
|
+
}
|
|
110
125
|
/** Creates this {@link DEFINED }. */
|
|
111
126
|
public constructor() {
|
|
112
127
|
super();
|