internal/policy/topic.go

d298215429fa4946ce82afebe7364ad178725e7b
gitbay/internal/policy/topic.go

20 lines · 532 bytes

 1package policy
 2
 3import (
 4	"fmt"
 5	"regexp"
 6)
 7
 8// MaxTopics caps topics per repository.
 9const MaxTopics = 20
10
11var topicPat = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,34}$`)
12
13// ValidateTopic checks a repository topic: lowercase alphanumerics and
14// dashes, must start with an alphanumeric, max 35 chars.
15func ValidateTopic(topic string) error {
16	if !topicPat.MatchString(topic) {
17		return fmt.Errorf("invalid topic %q: lowercase letters, digits, and '-' only; must start with a letter or digit; max 35 chars", topic)
18	}
19	return nil
20}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form