import T from "t-type-check";
const isDoorData = T({
type: T("open", "close"),
data: T.mapOf(T.int, T.bool).optional
});
isDoorData({type: "open", data: {"door1": true, "door2": 20}}) // true
isDoorData({type: "open"}) // true
isDoorData({type: "close", data: {"door3": 32.5}}) // false
const data = {type: "break", data: {"door1": true}}
const doorsData = isDoorData.assert(data, "wrong door format"); // throws error
-
Notifications
You must be signed in to change notification settings - Fork 0
flinbein/t-type-check
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Packages 0
No packages published