validator

package
v1.75.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 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 any) error

func ValidateNonNegativeInt

func ValidateNonNegativeInt(v any) error

func ValidateRequiredString

func ValidateRequiredString(v any) error

Types

type Secured added in v0.62.0

type Secured interface {
	SecureValue() string
}

type ValidateArg

type ValidateArg struct {
	Name  string
	Value any
	Fn    ValidateFunc
}

type ValidateFunc

type ValidateFunc func(v any) 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