validator

package
v0.106.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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