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.
cqtu/contest/validators.py

28 lines
914 B

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}(?:-[0-9])??$'
message = _(
'Enter a valid Callsign as Username, ALL UPPERCASE, if needed with -1 / -2,'
'e.g. DL7BST, DN1BER-1, DL/OE1FOO.'
)
flags = re.ASCII if six.PY3 else 0
@deconstructible
class CallLogValidator(validators.RegexValidator):
#regex = r'^[\w.@+-]+$'
regex = r'^(?:[A-Z]+/)?[A-Z]{1,2}[0-9][A-Z]{1,4}(?:-[0-9])?(?:/[A-Z]{1,3})?$'
message = _(
'Enter a valid callsign, ALL UPPERCASE, if needed with -1 / -2,'
'e.g. DL7BST, DN1BER-1, DL/OE1FOO, DN1FTW-1/p'
)
flags = re.ASCII if six.PY3 else 0