summaryrefslogtreecommitdiff
path: root/store/misc.go
blob: fd5f474a16bf605c8e1db787b8f8fe2248398e3d (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package store

import (
	"errors"
	"regexp"
)

const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

const (
	// Artist is the tag type artist.
	Artist = "artist"
	// Character is the tag type character.
	Character = "character"
	// Copyright is the tag type copyright.
	Copyright = "copyright"
	// Generic is the tag type generic.
	Generic = "generic"
	// Group is the tag type group.
	Group = "group"
	// Meta is the tag type meta.
	Meta = "meta"
)

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)
}