Skip to content

Commit

Permalink
feat: support new ssn intermediary characters
Browse files Browse the repository at this point in the history
  • Loading branch information
voneiden committed Dec 27, 2023
1 parent d75eb2f commit 247a10f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion profiles/tests/profile_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_adding_address_with_invalid_country_code_value_causes_a_validation_erro

def test_giving_invalid_ssn_causes_a_validation_error(self, user_gql_client):
profile_input = {
"sensitivedata": {"ssn": "101010X1234"},
"sensitivedata": {"ssn": "101010H1234"},
}

executed = self._execute_query(user_gql_client, profile_input)
Expand Down
4 changes: 4 additions & 0 deletions profiles/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ def test_ssn(self):

self.fails_validation(sensitive_data)

for intermediary in "+-ABCDEFUVWXX":
sensitive_data.ssn = f"150977{intermediary}5554"
self.passes_validation(sensitive_data)


class TestVerifiedPersonalInformationValidation(ValidationTestBase):
@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion profiles/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def validate_visible_latin_characters_only(value: str) -> None:
# It checks the allowed characters, but e.g. doesn't notice
# non-existing dates or calculate the checksum.
_finnish_national_identification_number_validator = RegexValidator(
regex="^[0-3][0-9][0-1][0-9]{3}[A+-][0-9]{3}[0-9A-Y]$",
regex="^[0-3][0-9][0-1][0-9]{3}[ABCDEFUVWXY+-][0-9]{3}[0-9A-Y]$",
message=_("Invalid Finnish personal identity code"),
)

Expand Down

0 comments on commit 247a10f

Please sign in to comment.