Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorise les apostrophes dans les inputs utilisateurs #599

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
smdsgn marked this conversation as resolved.
Show resolved Hide resolved


def is_alpha_validator(value: str) -> bool:
Expand Down