typescanner
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "typescanner", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A simple library for implementing type guard in TypeScript.", | ||
@@ -5,0 +5,0 @@ "author": "yona3", |
@@ -157,2 +157,21 @@ # typescanner | ||
### Debugging with scannar | ||
If you want to see which field has the problem, set `outputLog` to `true`. | ||
> **WARNING**: If the scanner is nested, it may not output logs as expected. | ||
```ts | ||
const isBar = scanner<Bar>({ | ||
a: string, | ||
b: number, | ||
}, { outputLog: true }) | ||
// throw error | ||
if (!isBar(data)) throw new Error("data is invalid") | ||
// Error: value.${key} does not meet the condition. | ||
``` | ||
### scan | ||
@@ -167,3 +186,3 @@ `scan` is used with the first argument being the value you want to validate and the second argument being the `Condition`. | ||
// Error! | ||
const data = scan(bar as unknown, isFoo); // Error: value.key does not meet the condition. | ||
const data = scan(bar as unknown, isFoo); // Error: type assertion is failed. | ||
``` | ||
@@ -193,2 +212,6 @@ | ||
// isUnion | ||
isUnion<string | number>(1, isString, isNumber) | ||
// isObject | ||
@@ -195,0 +218,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24233
262