validator

package
v0.0.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxBranchNameLength = 40

	ReValidRef  = regexp.MustCompile(`^\w+/?\w+$`)
	ReValidRepo = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_\-]{1,61}[a-zA-Z0-9]$`)
	ReValidUser = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_-]{1,28}[a-zA-Z0-9]$`)
	ReValidPath = regexp.MustCompile(`^[^\x00/:*?"<>|]*/?([^/\s\x00:*?"<>|]+/)*[^/\s\x00:*?"<>|]+(?:\.[a-zA-Z0-9]+)?$`)

	// RepoNameBlackList forbid repo name, reserve for routes
	RepoNameBlackList = []string{"repository", "repositories", "wip", "wips", "object", "objects", "commit", "commits", "ref", "refs", "repo", "repos", "user", "users"}
)
View Source
var (
	ErrNameBlackList     = errors.New("repository name is black list")
	ErrNameTooLong       = errors.New("name too long")
	ErrBranchFormat      = errors.New("branch format must be <name> or <name>/<name>")
	ErrInvalidBranchName = errors.New("invalid branch name: must start with a number or letter and can only contain numbers, letters, hyphens or underscores")
	ErrInvalidRepoName   = errors.New("repository name must start with a number or letter, can only contain numbers, letters, or hyphens, and must be between 3 and 63 characters in length")
	ErrInvalidUsername   = errors.New("invalid username: it must start and end with a letter or digit, can contain letters, digits, hyphens, and cannot start or end with a hyphen; the length must be between 3 and 30 characters")
	ErrInvalidObjectPath = errors.New("invalid object path: it must not contain null characters or NTFS forbidden characters")
)

Functions

func ValidateBranchName

func ValidateBranchName(name string) error

func ValidateObjectPath

func ValidateObjectPath(path string) error

func ValidateRepoName

func ValidateRepoName(name string) error

func ValidateUsername

func ValidateUsername(name string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL