Repository: identique/idnumbers (language: python)

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


Discussion / hints:
https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/San-Marino-TIN.pdf

Fix patch:
diff --git a/idnumbers/nationalid/SMR.py b/idnumbers/nationalid/SMR.py
new file mode 100644
index 00000000..970fc955
--- /dev/null
+++ b/idnumbers/nationalid/SMR.py
@@ -0,0 +1,62 @@
+import re
+from types import SimpleNamespace
+
+from .util import validate_regexp
+
+
+class SocialSecurityNumber:
+    """
+    San Marino, individual social security number, SSI number
+    https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/San-Marino-TIN.pdf
+    """
+    METADATA = SimpleNamespace(**{
+        'iso3166_alpha2': 'SM',
+        'min_length': 9,
+        'max_length': 9,
+        # length without insignificant chars
+        'parsable': False,
+        # has parse function
+        'checksum': False,
+        # has checksum function
+        'regexp': re.compile(r'^\d{9}$')
+        # regular expression to validate the id
+    })
+
+    @staticmethod
+    def validate(id_number: str) -> bool:
+        """
+        Validate
+        """
+        return validate_regexp(id_number, SocialSecurityNumber.METADATA.regexp)
+
+
+class TaxRegistrationNumber:
+    """
+    San Marino, entity tax registration number, COE number
+    https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/San-Marino-TIN.pdf
+    """
+    METADATA = SimpleNamespace(**{
+        'iso3166_alpha2': 'SM',
+        'min_length': 7,
+        'max_length': 7,
+        # length without insignificant chars
+        'parsable': False,
+        # has parse function
+        'checksum': False,
+        # has checksum function
+        'regexp': re.compile(r'^SM\d{5}$')
+        # regular expression to validate the id
+    })
+
+    @staticmethod
+    def validate(id_number: str) -> bool:
+        """
+        Validate
+        """
+        return validate_regexp(id_number, TaxRegistrationNumber.METADATA.regexp)
+
+
+NationalID = SocialSecurityNumber
+"""
+alias of SocialSecurityNumber
+"""


Test patch:
diff --git a/tests/nationalid/test_SMR.py b/tests/nationalid/test_SMR.py
new file mode 100644
index 00000000..7e05e3fd
--- /dev/null
+++ b/tests/nationalid/test_SMR.py
@@ -0,0 +1,17 @@
+from unittest import TestCase, main
+
+from idnumbers.nationalid import SMR
+
+
+class TestSMRValidation(TestCase):
+    def test_normal_case(self):
+        self.assertTrue(SMR.NationalID.validate('123456789'))
+        self.assertTrue(SMR.TaxRegistrationNumber.validate('SM12345'))
+
+    def test_error_case(self):
+        self.assertFalse(SMR.NationalID.validate('a12345678'))
+        self.assertFalse(SMR.TaxRegistrationNumber.validate('Sm12345'))
+
+
+if __name__ == '__main__':
+    main()