summaryrefslogtreecommitdiff
path: root/store/misc.go
blob: a1371988ef1a4b54051105c018de83eedc9c898b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package store

import (
	"errors"
	"regexp"
)

const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

var (
	nameRegex   = regexp.MustCompile(`^[a-z0-9()_-]{3,}$`)
	sha256Regex = regexp.MustCompile(`\b[A-Fa-f0-9]{64}\b`)
	secretRegex = regexp.MustCompile(`\b[A-Za-z]{64}\b`)
	urlRegex    = regexp.MustCompile(`(\b(https?|ftp)://)?[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]`)
)

var (
	// AlreadyExists is returned when store already exists.
	AlreadyExists = errors.New("store path already exists")
)

func (s *Store) MatchName(subject string) bool {
	return nameRegex.MatchString(subject)
}