argtool

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_OUT_OF_RANGE                = "out of range"
	ERR_NON_NEGATIVE_INTENGER       = "should be a non-negative integer"
	ERR_NON_NEGATIVE_INTENGER_SLICE = "should be a non-negative integer slice"
	ERR_NEGATIVE_INTENGER           = "should be a negative integer"
	ERR_NON_NEGATIVE_NUMBER         = "should be a non-negative number"
	ERR_NON_NEGATIVE_NUMBER_SLICE   = "should be a non-negative number slice"
	ERR_NAN_OR_INFINITY             = "cannot be -inf, +inf or NaN"
	ERR_EMPTY_STRING                = "cannot be an empty string"
	ERR_INVALID_INTEGER_ASSERTION   = "specified integer %d is invalid"
)

Reason

Variables

This section is empty.

Functions

func Assert

func Assert(errs ...error) error

func JsonInteger

func JsonInteger(v json.Number, name string, validators ...IntegerValidator) error

func JsonNumber

func JsonNumber(v json.Number, name string, validators ...FloatValidator) error

func NonEmptyString

func NonEmptyString(v string, name string) error

func NonNanNorInf

func NonNanNorInf(v float64, name string) error

func NonNegativeInteger

func NonNegativeInteger[T NonNegative_Integer](v T, name string) error

func NonNegativeIntegerSlice added in v0.0.19

func NonNegativeIntegerSlice[T Slice_NonNegative_Integer](v T, name string) error

func NonNegativeNumber

func NonNegativeNumber[T NonNegative_Number](v T, name string) error

func NonNegativeNumberSlice added in v0.0.19

func NonNegativeNumberSlice[T Slice_NonNegative_Number](v T, name string) error

func ThrowError

func ThrowError(name, reason string) error

Types

type FloatValidator

type FloatValidator func(v float64, name string) error

func RangeBetweenFloat

func RangeBetweenFloat(min, max float64) FloatValidator

type IntegerValidator

type IntegerValidator func(v int64, name string) error

func IntegerNotIn

func IntegerNotIn(values ...int64) IntegerValidator

func RangeBetween

func RangeBetween(min, max int64) IntegerValidator

type InvalidArgumentError

type InvalidArgumentError struct {
	Name   string
	Reason string
	Err    error
}

func (*InvalidArgumentError) Error

func (e *InvalidArgumentError) Error() string

func (*InvalidArgumentError) Unwrap

func (e *InvalidArgumentError) Unwrap() error

Unwrap returns the underlying error.

type Negative_Integer added in v0.0.19

type Negative_Integer interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

type NonNegative_Integer added in v0.0.17

type NonNegative_Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type NonNegative_Number added in v0.0.17

type NonNegative_Number interface {
	~float32 | ~float64 | ~complex64 | ~complex128
}

type Slice_Negative_Integer added in v0.0.19

type Slice_Negative_Integer interface {
	~[]uint64 | ~[]uint32 | ~[]uint16 | ~[]uint8 | ~[]uint
}

type Slice_NonNegative_Integer added in v0.0.19

type Slice_NonNegative_Integer interface {
	~[]int64 | ~[]int32 | ~[]int16 | ~[]int8 | ~[]int
}

type Slice_NonNegative_Number added in v0.0.19

type Slice_NonNegative_Number interface {
	~[]float64 | ~[]float32 | ~[]complex64 | ~[]complex128
}

Jump to

Keyboard shortcuts

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