From 7f4ebca0c4330805ea8f3821dba075b34dd2be58 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 1 Sep 2020 19:56:08 +0530 Subject: validation --- packages/taler-wallet-core/src/util/codec.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'packages/taler-wallet-core/src/util') diff --git a/packages/taler-wallet-core/src/util/codec.ts b/packages/taler-wallet-core/src/util/codec.ts index 111abc38c..741a5b172 100644 --- a/packages/taler-wallet-core/src/util/codec.ts +++ b/packages/taler-wallet-core/src/util/codec.ts @@ -292,15 +292,17 @@ export function codecForNumber(): Codec { /** * Return a codec for a value that must be a number. */ -export const codecForBoolean: Codec = { - decode(x: any, c?: Context): boolean { - if (typeof x === "boolean") { - return x; - } - throw new DecodingError( - `expected boolean at ${renderContext(c)} but got ${typeof x}`, - ); - }, +export function codecForBoolean(): Codec { + return { + decode(x: any, c?: Context): boolean { + if (typeof x === "boolean") { + return x; + } + throw new DecodingError( + `expected boolean at ${renderContext(c)} but got ${typeof x}`, + ); + }, + } }; /** -- cgit v1.2.3