mediacms/users/validators.py

16 lines
434 B
Python
Raw Permalink Normal View History

2020-12-15 22:33:43 +01: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 17:35:21 +02:00
message = _("Enter a valid username. This value may contain only " "English letters and numbers")
2020-12-15 22:33:43 +01:00
flags = re.ASCII
custom_username_validators = [ASCIIUsernameValidator()]