aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/iban.test.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-03-29 18:49:06 +0200
committerFlorian Dold <florian@dold.me>2023-03-29 18:50:07 +0200
commita17a08ae287a46e837c9a691caebdd029a07dc62 (patch)
tree519b14cde985a19fdfd9063c08662dadb107b40e /packages/taler-util/src/iban.test.ts
parente311dc4bef5e50ee7f797d5ff08309a63a43568d (diff)
downloadwallet-core-a17a08ae287a46e837c9a691caebdd029a07dc62.tar.xz
implement IBAN validation
Diffstat (limited to 'packages/taler-util/src/iban.test.ts')
-rw-r--r--packages/taler-util/src/iban.test.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/taler-util/src/iban.test.ts b/packages/taler-util/src/iban.test.ts
new file mode 100644
index 000000000..69fb2dd75
--- /dev/null
+++ b/packages/taler-util/src/iban.test.ts
@@ -0,0 +1,32 @@
+/*
+ This file is part of GNU Taler
+ (C) 2023 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+import test from "ava";
+import { generateIban, validateIban } from "./iban.js";
+
+test("iban validation", (t) => {
+ t.assert(validateIban("foo").type === "invalid");
+ t.assert(validateIban("NL71RABO9996666778").type === "valid");
+ t.assert(validateIban("NL71RABO9996666779").type === "invalid");
+});
+
+
+
+test("iban generation", (t) => {
+ let iban1 = generateIban("DE", 10);
+ console.log("generated IBAN", iban1);
+ t.assert(validateIban(iban1).type === "valid");
+});