update validators and wording
This commit is contained in:
31
fet2020/members/validators.py
Normal file
31
fet2020/members/validators.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from django.core.validators import RegexValidator, ValidationError
|
||||
from django.utils.deconstruct import deconstructible
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
@deconstructible
|
||||
class PhoneNumberValidator(RegexValidator):
|
||||
regex = r"^\+?1?\d{9,15}$"
|
||||
message = _(
|
||||
"Telefonnummer muss in diesem Format +999999999999 eingegeben werden. "
|
||||
"Bis zu 15 Zahlen sind erlaubt."
|
||||
)
|
||||
|
||||
|
||||
def validate_domainonly_email(value):
|
||||
if not "fet.at" in value:
|
||||
raise ValidationError(_("In der Mailadresse fehlt die richtige Domäne."))
|
||||
|
||||
def validate_file_size(value):
|
||||
if value.size > 10 * 1024 * 1024:
|
||||
raise ValidationError(_("Die maximale Dateigröße ist 10MB."))
|
||||
|
||||
def validate_image_dimension(value):
|
||||
if value.height < 150 or value.width < 150:
|
||||
raise ValidationError(
|
||||
_("Das Bild ist zu klein. (Höhe: %(height)s, Breite: %(width)s)"),
|
||||
params={
|
||||
"height": value.height,
|
||||
"width": value.width,
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user