Repository: identique/idnumbers (language: python)

Issue:
id number for Moldova
https://en.wikipedia.org/wiki/National_identification_number#Moldova


Discussion / hints:

Fix patch:
diff --git a/idnumbers/nationalid/MDA.py b/idnumbers/nationalid/MDA.py
new file mode 100644
index 00000000..7bd9474b
--- /dev/null
+++ b/idnumbers/nationalid/MDA.py
@@ -0,0 +1,34 @@
+import re
+from types import SimpleNamespace
+
+from .util import validate_regexp
+
+
+class PersonalCode:
+    """
+    Moldova Personal Code, IDNP
+    https://en.wikipedia.org/wiki/National_identification_number#Moldova
+    """
+    METADATA = SimpleNamespace(**{
+        'iso3166_alpha2': 'MD',
+        # length without insignificant chars
+        'min_length': 13,
+        'max_length': 13,
+        # has parse function
+        'parsable': False,
+        # has checksum function
+        'checksum': False,
+        # regular expression to validate the id
+        'regexp': re.compile(r'^\d{13}$')
+    })
+
+    @staticmethod
+    def validate(id_number: str) -> bool:
+        """
+        Validate the personal code
+        """
+        return validate_regexp(id_number, PersonalCode.METADATA.regexp)
+
+
+NationalID = PersonalCode
+"""alias of PersonalCode"""


Test patch:
diff --git a/tests/nationalid/test_MDA.py b/tests/nationalid/test_MDA.py
new file mode 100644
index 00000000..4d11a8d4
--- /dev/null
+++ b/tests/nationalid/test_MDA.py
@@ -0,0 +1,15 @@
+from unittest import TestCase, main
+from idnumbers.nationalid import MDA
+
+
+class TestMDANationalIDValidation(TestCase):
+    def test_normal_case(self):
+        self.assertTrue(MDA.PersonalCode.validate('1234567890123'))
+
+    def test_error_case(self):
+        self.assertFalse(MDA.PersonalCode.validate('123456789012'))
+        self.assertFalse(MDA.PersonalCode.validate('1234A67890123'))
+
+
+if __name__ == '__main__':
+    main()