cqtu/contest/validators.py

26 lines
793 B
Python
Raw Normal View History

2017-01-20 14:28:59 +01:00
from django.core import validators
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _
2017-01-20 14:28:59 +01:00
import re
@deconstructible
class CallUsernameValidator(validators.RegexValidator):
regex = r'^(?:[A-Z]+/)?[A-Z]{1,2}[0-9][A-Z]{1,4}(?:-[0-9])??$'
2017-01-20 14:28:59 +01:00
message = _(
'Enter a valid Callsign as Username, ALL UPPERCASE, if needed with -1 / -2,'
'e.g. DL7BST, DN1BER-1, DL/OE1FOO.'
)
flags = re.ASCII
@deconstructible
class CallLogValidator(validators.RegexValidator):
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'
2017-01-20 14:28:59 +01:00
)
flags = re.ASCII