validator

package
v0.1.8-test Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReValidRef          = regexp.MustCompile(`^[^\s]+$`)
	ReValidBranchID     = regexp.MustCompile(`^\w[-\w]*$`)
	ReValidRepositoryID = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{2,62}$`)
)
View Source
var (
	ErrInvalid           = errors.New("validation error")
	ErrInvalidType       = fmt.Errorf("invalid type: %w", ErrInvalid)
	ErrRequiredValue     = fmt.Errorf("required value: %w", ErrInvalid)
	ErrInvalidValue      = fmt.Errorf("invalid value: %w", ErrInvalid)
	ErrPathRequiredValue = fmt.Errorf("missing path: %w", ErrRequiredValue)
)

Functions

func Validate

func Validate(args []ValidateArg) error

func ValidateNonNegativeInt

func ValidateNonNegativeInt(v interface{}) error

func ValidateRequiredString

func ValidateRequiredString(v interface{}) error

Types

type Secured added in v0.62.0

type Secured interface {
	SecureValue() string
}

type ValidateArg

type ValidateArg struct {
	Name  string
	Value interface{}
	Fn    ValidateFunc
}

type ValidateFunc

type ValidateFunc func(v interface{}) error

func MakeValidateOptional

func MakeValidateOptional(fn ValidateFunc) ValidateFunc

Jump to

Keyboard shortcuts

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