param

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](v T) *T

Ptr simply returns a pointer to a literal. e.g. Ptr(0.5) This is useful when passing literals to functions which require pointers to basic types.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

Bool is a boolean parameter

func NewBool

func NewBool(name, description string) Bool

NewBool creates a new boolean param

func (Bool) Description

func (i Bool) Description() string

func (Bool) Name

func (i Bool) Name() string

type ErrInvalidType

type ErrInvalidType struct {
	FoundType    string
	ExpectedType string
}

func (ErrInvalidType) Error

func (e ErrInvalidType) Error() string

type ErrInvalidValue

type ErrInvalidValue struct {
	ParameterName string
	Value         string
	Context       *string // optional context
}

func (ErrInvalidValue) Error

func (e ErrInvalidValue) Error() string

type ErrUnrecognizedOption

type ErrUnrecognizedOption struct {
	Option string
}

func (ErrUnrecognizedOption) Error

func (e ErrUnrecognizedOption) Error() string

type ErrValueOutOfRange

type ErrValueOutOfRange struct {
	Min *string
	Max *string
}

func (ErrValueOutOfRange) Error

func (e ErrValueOutOfRange) Error() string

type Float

type Float struct {
	// contains filtered or unexported fields
}

Float is a float parameter with optional min and max constraints

func NewFloat

func NewFloat(name, description string, min, max *float64) Float

NewFloat creates a new float param with optional min/max constraints

func (Float) Description

func (i Float) Description() string

func (Float) Max

func (f Float) Max() *float64

func (Float) Min

func (f Float) Min() *float64

func (Float) Name

func (i Float) Name() string

type Int

type Int struct {
	// contains filtered or unexported fields
}

Int is an int parameter with optional min and max constraints

func NewInt

func NewInt(name, description string, min, max *int) Int

NewInt creates a new int param with optional min/max constraints

func (Int) Description

func (i Int) Description() string

func (Int) Max

func (i Int) Max() *int

func (Int) Min

func (i Int) Min() *int

func (Int) Name

func (i Int) Name() string

type List

type List []ParamInterface

List is a slice of ParamInterface

type ParamInterface

type ParamInterface interface {
	Name() string
	Description() string
}

ParamInterface provides an interface to a parameter

type ParametersInterface

type ParametersInterface interface {
	ParameterList() List

	ValidateParam(param *keyvalue.KeyValue) error
}

Add a ParametersInterface to a struct to store and validate parameters

func NewParameters

func NewParameters(params List) ParametersInterface

type Str

type Str struct {
	// contains filtered or unexported fields
}

Str is a string parameter

func NewStr

func NewStr(name, description string, validValues []string) Str

NewStr creates a new string param with optional list of valid values

func (Str) Description

func (i Str) Description() string

func (Str) Name

func (i Str) Name() string

func (Str) ValidValues

func (s Str) ValidValues() []string

Jump to

Keyboard shortcuts

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