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.

validators.py 685B

12345678910111213141516171819202122232425
  1. import re
  2. from django.core import validators
  3. from django.utils.deconstruct import deconstructible
  4. from django.utils.translation import gettext_lazy as _
  5. @deconstructible
  6. class ASCIIUsernameValidator(validators.RegexValidator):
  7. regex = r'^[\w.@+-]+$'
  8. message = _(
  9. 'Enter a valid username. This value may contain only English letters, '
  10. 'numbers, and @/./+/-/_ characters.'
  11. )
  12. flags = re.ASCII
  13. @deconstructible
  14. class UnicodeUsernameValidator(validators.RegexValidator):
  15. regex = r'^[\w.@+-]+$'
  16. message = _(
  17. 'Enter a valid username. This value may contain only letters, '
  18. 'numbers, and @/./+/-/_ characters.'
  19. )
  20. flags = 0