tkPresentation

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// spf13/cobra (cli lib) does not support nil or pointers as default values.
	// UnsetParameterValueStr is a special value to circumvent this limitation.
	UnsetParameterValueStr string = "__UNSET__"
)

Variables

This section is empty.

Functions

func ParamConstructorWrapper added in v0.0.3

func ParamConstructorWrapper[objectInstance any](
	objectConstructor func(any) (objectInstance, error),
) func(any) (any, error)

Go requires exact function signature matches, unless using generics to infer type. Hence, this wrapper must be used when creating the KnownParamConstructors map.

func StringSliceValueObjectParser

func StringSliceValueObjectParser[TypedObject any](
	rawInputValues any,
	valueObjectConstructor func(any) (TypedObject, error),
) []TypedObject

StringSliceValueObjectParser converts various input formats into a slice of typed objects. It accepts: - nil (returns empty slice) - string (splits by ";" or "," and parses each element) - slice (parses each element) - single value (parses as one element)

The valueObjectConstructor function is used to convert each raw value into the desired type. Invalid values are logged and skipped.

Types

type RequestInputParsed added in v0.0.3

type RequestInputParsed struct {
	KnownParams      map[string]any
	KnownParamErrors map[string]error
	ClearableParams  map[string]any
	UnknownParams    map[string]any
}

func RequestInputParser added in v0.0.3

func RequestInputParser(
	componentSettings RequestInputSettings,
) (requestInputParsed RequestInputParsed)

type RequestInputSettings added in v0.0.3

type RequestInputSettings struct {
	RawRequestInput        map[string]any
	KnownParamConstructors map[string]func(any) (any, error)
}

Jump to

Keyboard shortcuts

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