@briklab/lib/jstc
Runtime type validation for JavaScript values with configurable protection levels.
Runtime Validation Only
JSTC validates at runtime and does not replace TypeScript compile-time type checking.
API
- Classes:
JSTypeChecker - Types:
ProtectionLevel,JSType,JSTypeOrArray - Constants:
JSTC
Quick Start
ts
import JSTC from "@briklab/lib/jstc";
JSTC.setProtectionLevel("boundary");
const isValid = JSTC.for([42]).check(["number"]); // trueFeatures
- Singleton Pattern: Use the
JSTCconstant for quick, shared type checking - Custom Instances: Create
JSTypeCheckerinstances for isolated validation - Protection Levels: Control validation strictness with different protection levels
Diagram
Live Demo
Recommended to test it in your browser. The test here might not work properly
Console
No logs yet.
