xarg

package
v1.4.10 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResemblesProviderFunction

func ResemblesProviderFunction(dt reflect.Type) bool

func SiftValidators

func SiftValidators(
	validators []any,
	root *reflect.Value,
	bindKind BindKind,
) ([]any, []any, error)

SiftValidators iterates through all the given validators, sifting them into two categories: pre-parse validators and post-parse validators.

Validators are all confirmed to be function types that expect and return the correct number and types of values. If any of the given values does not match one of the expected validator function forms, an error will be returned.

The valid function forms that are allowed are:

func(string) error
// and
func(T, string) error

In the above example, the type T must match the given binding type passed as the second argument to this function.

func ValidateDoubleValidator

func ValidateDoubleValidator(idx int, vt reflect.Type, bt reflect.Type) error

ValidateDoubleValidator tests the given function to ensure the double parameter function accepts the expected types.

func ValidateSoloValidator

func ValidateSoloValidator(idx int, vt reflect.Type) error

ValidateSoloValidator tests the given function to ensure the singular parameter function accepts the expected type.

func ValidateValidator

func ValidateValidator(
	idx int,
	validator any,
	bt reflect.Type,
	includePostParse bool,
) (uint8, error)

ValidateValidator tests the given value (validator) to ensure that it is of a valid validator function type.

See SiftValidators for more details about what constitutes a valid validator function.

Types

type BindKind

type BindKind uint8
const (
	BindKindNone BindKind = iota
	BindKindPointer
	BindKindUnmarshaler
	BindKindFuncPlain
	BindKindFuncWithErr
	BindKindUnknown = 254
	BindKindInvalid = 255
)

func DetermineBindKind

func DetermineBindKind(bind any, ut reflect.Type) (kind BindKind, err error)

type DefaultKind

type DefaultKind uint8
const (
	DefaultKindNone DefaultKind = iota
	DefaultKindRaw
	DefaultKindParsed
	DefaultKindProviderPlain
	DefaultKindProviderWithErr
	DefaultKindUnknown = 254
	DefaultKindInvalid = 255
)

func DetermineDefaultKind

func DetermineDefaultKind(bind, def any) (kind DefaultKind, err error)

Jump to

Keyboard shortcuts

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