validator

package
v0.0.0-...-6bdf688 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Email       string = "" /* 1212-byte string literal not displayed */
	UUID        string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
	UUIDPattern string = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"

	VolumeNamePattern      string = `^[a-zA-Z0-9_\-]{1,64}$`
	VolumeNamespacePattern string = `^[a-zA-Z0-9_\-]{1,64}$`
	BranchPattern          string = `^[a-zA-Z0-9_\-]{1,64}$`
	SubDotPattern          string = `^[a-zA-Z0-9_\-]{1,64}$`
	SnapshotPattern        string = `^[a-zA-Z0-9_\-]{1,64}$`
)

url checking consts

Variables

View Source
var (
	ErrEmptyName            = errors.New("name cannot be empty")
	ErrEmptyNamespace       = errors.New("namespace cannot be empty")
	ErrEmptySubdot          = errors.New("subdot cannot be empty")
	ErrEmptySnapshot        = errors.New("snapshot cannot be empty")
	ErrInvalidVolumeName    = fmt.Errorf("invalid dot name, should match pattern: %s", VolumeNamePattern)
	ErrInvalidNamespaceName = fmt.Errorf("invalid namespace name, should match pattern: %s", VolumeNamespacePattern)
	ErrInvalidBranchName    = fmt.Errorf("invalid branch name, should match pattern: %s", BranchPattern)
	ErrInvalidSubdotName    = fmt.Errorf("invalid subdot name, should match pattern: %s", SubDotPattern)
	ErrInvalidSnapshotName  = fmt.Errorf("invalid snapshot name, should match pattern: %s", SnapshotPattern)
)

errors

Functions

func EnsureValidOrRespond

func EnsureValidOrRespond(value string, validator ValidatorFunc, resp http.ResponseWriter) bool

Return false (and respond with HTTP error) if the value doesn't validate.

func IsEmail

func IsEmail(str string) bool

IsEmail check if the string is an email.

func IsUUID

func IsUUID(str string) bool

IsUUID check if the string is a UUID (version 3, 4 or 5).

func IsValidBranchName

func IsValidBranchName(str string) error

func IsValidPassword

func IsValidPassword(str string) (errs []string)

IsValidPassword - checks is user supplied password is valid

func IsValidSnapshotName

func IsValidSnapshotName(str string) error

func IsValidSubdotName

func IsValidSubdotName(str string) error

func IsValidVolume

func IsValidVolume(namespace, name string) error

func IsValidVolumeName

func IsValidVolumeName(str string) error

func IsValidVolumeNamespace

func IsValidVolumeNamespace(str string) error

func ReplaceUUID

func ReplaceUUID(str, replace string) string

ReplaceUUID replace UUID in string

Types

type ValidatorFunc

type ValidatorFunc func(string) error

Jump to

Keyboard shortcuts

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