Add $ marker to validation regexes

..else they won't match the whole string.
This commit is contained in:
Sebastian Lohff 2018-06-17 19:48:36 +02:00
parent ac3e676e45
commit 8a162acee3
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import ipaddress
@deconstructible
class HandleValidator(validators.RegexValidator):
regex = r'^(?:[A-Z]+[0-9]*(-[A-Z]+)|AUTO)'
regex = r'^(?:[A-Z]+[0-9]*(-[A-Z]+)|AUTO)$'
message = _(
'Enter a valid handle (all uppercase)'
)
@ -26,7 +26,7 @@ class HandleValidatorWithSuffix(validators.RegexValidator):
flags = re.ASCII if six.PY3 else 0
def __init__(self, suffix):
self.regex = r'^(?:[A-Z]+[0-9]*-%s|AUTO)' % re.escape(suffix)
self.regex = r'^(?:[A-Z]+[0-9]*-%s|AUTO)$' % re.escape(suffix)
self.message = _(
'Enter a valid handle with suffix %s (all uppercase), e.g. FOO3-%s' % (suffix, suffix)
)