expand regexp

This commit is contained in:
Cayo Puigdefabregas 2023-11-22 13:59:25 +01:00
parent 7a7036a228
commit f6b27d94ba
1 changed files with 4 additions and 2 deletions

View File

@ -15,7 +15,8 @@ class ProfileForm(forms.ModelForm):
def clean_first_name(self):
first_name = super().clean()['first_name']
if not re.match(r'^[a-zA-Z\s]+$', first_name):
match = r'^[a-zA-ZäöüßÄÖÜáéíóúàèìòùÀÈÌÒÙÁÉÍÓÚßñÑ\s\'-]+'
if not re.match(match, first_name):
txt = _("The string must contain only characters and spaces")
raise forms.ValidationError(txt)
@ -23,7 +24,8 @@ class ProfileForm(forms.ModelForm):
def clean_last_name(self):
last_name = super().clean()['last_name']
if not re.match(r'^[a-zA-Z\s]+$', last_name):
match = r'^[a-zA-ZäöüßÄÖÜáéíóúàèìòùÀÈÌÒÙÁÉÍÓÚßñÑ\s\'-]+'
if not re.match(match, last_name):
txt = _("The string must contain only characters and spaces")
raise forms.ValidationError(txt)