Last active
September 11, 2024 11:53
-
-
Save gartmeier/11163b2ea35f5774ddd658a0b422fb12 to your computer and use it in GitHub Desktop.
Soublick Assessment - Aufgabe 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.core.validators import RegexValidator | |
from django.utils.translation import gettext_lazy as _ | |
class ContactForm(forms.Form): | |
street_and_number = forms.CharField( | |
max_length=200, | |
label=_('Street and house number') | |
) | |
postal_code = forms.CharField( | |
max_length=4, | |
label=_('Postal code'), | |
validators=[ | |
MinValueValidator(1000, _('Invalid postal code')), | |
MaxValueValidator(9999, _('Invalid postal code')) | |
] | |
) | |
city = forms.CharField( | |
max_length=100, | |
label=_('City') | |
) | |
phone_number = forms.CharField( | |
max_length=20, | |
label=_('Phone number'), | |
validators=[ | |
RegexValidator( | |
regex=r'^(?:\+41|0)(?:\s*\d){9}\s*$', | |
message=_("Please specify a correct phone number, for example: +41 78 123 45 67") | |
), | |
] | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment