Skip to content

Commit

Permalink
Merge pull request #600 from MTES-MCT/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisig authored Oct 2, 2024
2 parents 4921457 + 105332b commit ce8a9ba
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions users/tests/SignupTest.py → users/tests/test_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
)
3 changes: 2 additions & 1 deletion utils/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ce8a9ba

Please sign in to comment.