summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-09-01 19:56:08 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-09-01 19:56:08 +0530
commit7f4ebca0c4330805ea8f3821dba075b34dd2be58 (patch)
tree39e9c0994969565ab9a227494beaf5e830315e9a /packages/taler-wallet-core/src/util
parent62406304d9a81a08797c09f5151de74d8ca43fe8 (diff)
downloadwallet-core-7f4ebca0c4330805ea8f3821dba075b34dd2be58.tar.gz
wallet-core-7f4ebca0c4330805ea8f3821dba075b34dd2be58.tar.bz2
wallet-core-7f4ebca0c4330805ea8f3821dba075b34dd2be58.zip
validation
Diffstat (limited to 'packages/taler-wallet-core/src/util')
-rw-r--r--packages/taler-wallet-core/src/util/codec.ts20
1 files changed, 11 insertions, 9 deletions
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<number> {
/**
* Return a codec for a value that must be a number.
*/
-export const codecForBoolean: Codec<boolean> = {
- 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<boolean> {
+ 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}`,
+ );
+ },
+ }
};
/**