xdbc 1.0.209 → 1.0.210
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/__tests__/DBC/IF.test.ts +8 -0
- package/package.json +1 -1
- package/src/DBC/IF.ts +2 -0
package/__tests__/DBC/IF.test.ts
CHANGED
|
@@ -48,5 +48,13 @@ describe("IF", () => {
|
|
|
48
48
|
test("Should return true when both condition and inCase pass", () => {
|
|
49
49
|
expect(IF.checkAlgorithm("hello", isString, eqHello)).toBe(true);
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
test("Should return true when toCheck is undefined", () => {
|
|
53
|
+
expect(IF.checkAlgorithm(undefined, isString, eqHello)).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("Should return true when toCheck is null", () => {
|
|
57
|
+
expect(IF.checkAlgorithm(null, isString, eqHello)).toBe(true);
|
|
58
|
+
});
|
|
51
59
|
});
|
|
52
60
|
});
|
package/package.json
CHANGED
package/src/DBC/IF.ts
CHANGED
|
@@ -24,6 +24,8 @@ export class IF extends DBC {
|
|
|
24
24
|
},
|
|
25
25
|
invert: boolean = false,
|
|
26
26
|
): boolean | string {
|
|
27
|
+
if (toCheck === undefined || toCheck === null) return true;
|
|
28
|
+
|
|
27
29
|
if (invert && condition.check(toCheck) !== true && inCase.check(toCheck) !== true) {
|
|
28
30
|
return `In case that the value does not comply to the condition, it also has to comply to the required contract`;
|
|
29
31
|
}
|