validation

package
v0.0.139 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: 0BSD Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidationTypeMap = map[string]*regexp.Regexp{
	"user_name":        regexp.MustCompile("^[a-z0-9]{3,20}$"),
	"app_name":         regexp.MustCompile("^[a-z0-9]{3,20}$"),
	"version_name":     regexp.MustCompile("^[a-z0-9.]{3,20}$"),
	"search_term":      regexp.MustCompile("^[a-z0-9]{0,20}$"),
	"password":         regexp.MustCompile("^[a-zA-Z0-9._-]{8,30}$"),
	"email":            regexp.MustCompile("^" + emailRegexSuffix),
	"number":           regexp.MustCompile("^[0-9]{1,20}$"),
	"host":             regexp.MustCompile("^[a-zA-Z0-9:._-]{0,64}$"),
	"known_hosts":      regexp.MustCompile(`^[A-Za-z0-9.:,/_+=#@\[\]| \r\n-]{0,}$`),
	"restic_backup_id": regexp.MustCompile(`^[a-f0-9]{64}$`),
	"remote_host":      regexp.MustCompile("^[a-zA-Z0-9._-]{0,64}$"),
	"email_or_empty":   regexp.MustCompile(`^$|^` + emailRegexSuffix),
}

Functions

func AssertYamlEquality

func AssertYamlEquality(t *testing.T, a, b []byte)

func CompleteDockerComposeYaml

func CompleteDockerComposeYaml(maintainer, appName, filePath, host string) error

func IsValidURLPath

func IsValidURLPath(path string) bool

func ReadBody added in v0.0.77

func ReadBody[T any](w http.ResponseWriter, r *http.Request) (*T, error)

func ValidateSecret added in v0.0.77

func ValidateSecret(input string) error

As we do not receive sensitive data in request bodies such as secrets or cookie values, this is a separate concern in a separate function.

func ValidateStruct added in v0.0.78

func ValidateStruct(s any) error

func ValidateVersion

func ValidateVersion(zipBytes []byte, maintainerName, appName string) error

func ZipDirectory

func ZipDirectory(dirPath string) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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