diff --git a/users/tests/SignupTest.py b/users/tests/test_signup.py similarity index 72% rename from users/tests/SignupTest.py rename to users/tests/test_signup.py index 6bada2480..3ffb507e9 100644 --- a/users/tests/SignupTest.py +++ b/users/tests/test_signup.py @@ -62,3 +62,30 @@ def test_signup_form_with_different_passwords(self) -> None: field="password2", errors="Les mots de passe ne sont pas identiques", ) + + def test_allowed_characters_are_accepted(self) -> None: + fields_to_test = { + "first_name": "John-Doe", + "last_name": "John Do'e", + "function": "Test", + } + + data = {**valid_payload, **fields_to_test} + + response = self.client.post(path=form_url, data=data) + self.assertFormError( + response=response, + form="form", + field=None, + errors=[], + ) + + def test_accents_are_accepted(self): + data = {**valid_payload, **{"first_name": "Jérôme"}} + response = self.client.post(path=form_url, data=data) + self.assertFormError( + response=response, + form="form", + field=None, + errors=[], + ) diff --git a/utils/validators.py b/utils/validators.py index 9e51b407f..657a32996 100644 --- a/utils/validators.py +++ b/utils/validators.py @@ -2,7 +2,8 @@ def is_alpha_valid(value: str) -> bool: - return all(char.isalpha() or char == " " or char == "-" for char in value) + special_chars_allowed = [" ", "-", "'"] + return all(char.isalpha() or char in special_chars_allowed for char in value) def is_alpha_validator(value: str) -> bool: