aboutsummaryrefslogtreecommitdiff
path: root/src/checkable.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-16 01:59:39 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-16 02:00:31 +0100
commitbd65bb67e25a79b019d745b7262b2008ce2adb15 (patch)
tree89e1b032103a63737f1a703e6a943832ef261704 /src/checkable.ts
parentf91466595b651721690133f58ab37f977539e95b (diff)
incrementally verify denoms
The denominations are not stored in a separate object store.
Diffstat (limited to 'src/checkable.ts')
-rw-r--r--src/checkable.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/checkable.ts b/src/checkable.ts
index b6ef49fac..c8cc27b26 100644
--- a/src/checkable.ts
+++ b/src/checkable.ts
@@ -72,6 +72,13 @@ export namespace Checkable {
return target;
}
+ function checkBoolean(target: any, prop: Prop, path: Path): any {
+ if (typeof target !== "boolean") {
+ throw new SchemaError(`expected boolean for ${path}, got ${typeof target} instead`);
+ }
+ return target;
+ }
+
function checkAnyObject(target: any, prop: Prop, path: Path): any {
if (typeof target !== "object") {
@@ -269,6 +276,11 @@ export namespace Checkable {
chk.props.push({ propertyKey: propertyKey, checker: checkString });
}
+ export function Boolean(target: Object, propertyKey: string | symbol): void {
+ let chk = mkChk(target);
+ chk.props.push({ propertyKey: propertyKey, checker: checkBoolean });
+ }
+
function mkChk(target: any) {
let chk = target[chkSym];