mediacms/users/validators.py

16 wiersze
434 B
Python
Czysty Zwykły widok Historia

2020-12-15 21:33:43 +00:00
import re
from django.core import validators
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _
@deconstructible
class ASCIIUsernameValidator(validators.RegexValidator):
regex = r"^[\w]+$"
2021-05-26 15:35:21 +00:00
message = _("Enter a valid username. This value may contain only " "English letters and numbers")
2020-12-15 21:33:43 +00:00
flags = re.ASCII
custom_username_validators = [ASCIIUsernameValidator()]