From bd65bb67e25a79b019d745b7262b2008ce2adb15 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 16 Nov 2016 01:59:39 +0100 Subject: incrementally verify denoms The denominations are not stored in a separate object store. --- src/checkable.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/checkable.ts') 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]; -- cgit v1.2.3