validate

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPositive    = errors.New("validate: value must be positive")
	ErrBetween     = errors.New("validate: value must be between")
	ErrNegative    = errors.New("validate: value must be negative")
	ErrNonNegative = errors.New("validate: value must be non-negative")
	ErrMax         = errors.New("validate: value must be less or equal than")
	ErrMin         = errors.New("validate: value must be greater or equal than")
	ErrDivisorZero = errors.New("validate: divisor cannot be zero")
	ErrMultipleOf  = errors.New("validate: value must be multiple of")
)

Functions

func Between

func Between[T Number](value, lowerBound, upperBound T) error

Between validates if a value is within the specified lower and upper bounds (inclusive).

func Max

func Max[T Number](value, upperBound T) error

Max validates if a value is less than or equal to the specified upper bound.

func Min

func Min[T Number](value, lowerBound T) error

Min validates if a value is greater than or equal to the specified lower bound.

func MultipleOf

func MultipleOf[T Integer](value, divisor T) error

MultipleOf validates if a value is a multiple of the specified divisor.

func Negative

func Negative[T Number](value T) error

Negative checks if the given numeric value is negative.

func NonNegative

func NonNegative[T Number](value T) error

NonNegative validates that the provided numeric value is non-negative (including zero).

func Positive

func Positive[T Number](value T) error

Positive checks if the provided value is positive (excluding zero).

Types

type Integer

type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~uintptr
}

type Number

type Number interface {
	Integer | ~float32 | ~float64
}

Jump to

Keyboard shortcuts

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