Repository: mdomke/schwifty (language: python)

Issue:
Add checksum validation for Netherlands



Discussion / hints:

Fix patch:
diff --git a/schwifty/checksum/__init__.py b/schwifty/checksum/__init__.py
index 220a1e7..2b8434b 100644
--- a/schwifty/checksum/__init__.py
+++ b/schwifty/checksum/__init__.py
@@ -38,3 +38,4 @@ def register(algorithm_cls: type[Algorithm], prefix: str | None = None) -> type[
 from schwifty.checksum import france  # noqa
 from schwifty.checksum import germany  # noqa
 from schwifty.checksum import italy  # noqa
+from schwifty.checksum import netherlands  # noqa
diff --git a/schwifty/checksum/netherlands.py b/schwifty/checksum/netherlands.py
new file mode 100644
index 0000000..234a1f9
--- /dev/null
+++ b/schwifty/checksum/netherlands.py
@@ -0,0 +1,23 @@
+import functools
+
+from schwifty import checksum
+
+
+register = functools.partial(checksum.register, prefix="NL")
+
+
+@register
+class DefaultAlgorithm(checksum.Algorithm):
+    name = "default"
+    accepts = checksum.InputType.BBAN
+
+    def compute(self, bban: str) -> str:
+        raise NotImplementedError("Cannot compute checksum for Netherlands")
+
+    def validate(self, bban: str) -> bool:
+        acc_number = bban[-10:]
+        total = 0
+        for i, digit in enumerate(map(int, acc_number)):
+            total += digit * (10 - i)
+
+        return total % 11 == 0


Test patch:
diff --git a/tests/test_checksum.py b/tests/test_checksum.py
index de2b874..0a81bee 100644
--- a/tests/test_checksum.py
+++ b/tests/test_checksum.py
@@ -101,3 +101,7 @@ def test_belgium_checksum_failure():
 
 def test_belgium_checksum_checksum_edge_case():
     assert algorithms["BE:default"].validate("050000017797") is True
+
+
+def test_netherlands_checksum():
+    assert algorithms["NL:default"].validate("0417164300") is True