19 lines
542 B
Python
19 lines
542 B
Python
from django.core import validators
|
|
from django.utils import six
|
|
from django.utils.deconstruct import deconstructible
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
import re
|
|
|
|
|
|
@deconstructible
|
|
class CallUsernameValidator(validators.RegexValidator):
|
|
#regex = r'^[\w.@+-]+$'
|
|
regex = r'^(?:[A-Z]+/)?[A-Z]{1,2}[0-9][A-Z]{1,4}(?:/[A-Z])?$'
|
|
message = _(
|
|
'Enter a valid Callsign as Username, ALL UPPERCASE, if needed with /A /B,'
|
|
'e.g. DL7BST, DN1BER/A, DL/OE1FOO'
|
|
)
|
|
flags = re.ASCII if six.PY3 else 0
|
|
|