2016-04-23 01:39:13 +08:00
|
|
|
import re
|
|
|
|
|
|
|
|
from django.core import validators
|
|
|
|
from django.utils.deconstruct import deconstructible
|
2017-01-27 03:58:33 +08:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2016-04-23 01:39:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
@deconstructible
|
|
|
|
class ASCIIUsernameValidator(validators.RegexValidator):
|
|
|
|
regex = r'^[\w.@+-]+$'
|
|
|
|
message = _(
|
|
|
|
'Enter a valid username. This value may contain only English letters, '
|
|
|
|
'numbers, and @/./+/-/_ characters.'
|
|
|
|
)
|
2016-12-01 18:38:01 +08:00
|
|
|
flags = re.ASCII
|
2016-04-23 01:39:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
@deconstructible
|
|
|
|
class UnicodeUsernameValidator(validators.RegexValidator):
|
|
|
|
regex = r'^[\w.@+-]+$'
|
|
|
|
message = _(
|
|
|
|
'Enter a valid username. This value may contain only letters, '
|
|
|
|
'numbers, and @/./+/-/_ characters.'
|
|
|
|
)
|
2016-12-01 18:38:01 +08:00
|
|
|
flags = 0
|