Aligning the naming constraints with git.sr.ht: - repository name must be at least one character, not two; - fist character can be uppercase (but not a numeric); - in general accepts only alphanumeric characters or ._-

~sircmpwn/todo.sr.ht#193
This commit is contained in:
Cédric Bonhomme 2019-11-01 19:28:03 +01:00 committed by Drew DeVault
parent 6ce73b2489
commit 732329c04e
1 changed files with 4 additions and 6 deletions

View File

@ -6,7 +6,7 @@ from srht.flagtype import FlagType
from srht.validation import Validation
from todosrht.types import TicketAccess, TicketStatus, TicketResolution
name_re = re.compile(r"^([a-z][a-z0-9_.-]*?)+$")
name_re = re.compile(r"^([A-Za-z._-][A-Za-z._-]*?)+$")
class Tracker(Base):
__tablename__ = 'tracker'
@ -63,13 +63,11 @@ class Tracker(Base):
if not valid.ok:
return None, valid
valid.expect(2 <= len(name) < 256,
"Must be between 2 and 255 characters",
valid.expect(1 <= len(name) < 256,
"Must be between 1 and 255 characters",
field="name")
valid.expect(not valid.ok or name[0] in string.ascii_lowercase,
"Must begin with a lowercase letter", field="name")
valid.expect(not valid.ok or name_re.match(name),
"Only lowercase alphanumeric characters or -.",
"Only alphanumeric characters or ._-",
field="name")
valid.expect(not desc or len(desc) < 4096,
"Must be less than 4096 characters",