validator

package
v1.31.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 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)
)

Functions

func Validate

func Validate(args []ValidateArg) error

func ValidateNilOrPositiveInt added in v0.97.0

func ValidateNilOrPositiveInt(v interface{}) 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