You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
687 B
25 lines
687 B
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.@+-]+\Z"
|
|
message = _(
|
|
"Enter a valid username. This value may contain only English letters, "
|
|
"numbers, and @/./+/-/_ characters."
|
|
)
|
|
flags = re.ASCII
|
|
|
|
|
|
@deconstructible
|
|
class UnicodeUsernameValidator(validators.RegexValidator):
|
|
regex = r"^[\w.@+-]+\Z"
|
|
message = _(
|
|
"Enter a valid username. This value may contain only letters, "
|
|
"numbers, and @/./+/-/_ characters."
|
|
)
|
|
flags = 0
|
|
|