assistant

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 12 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetThirdPartyCL added in v0.4.0

func GetThirdPartyCL(
	flagSet *pflag.FlagSet,
	knownBy cobrass.KnownByCollection,
) cobrass.ThirdPartyCommandLine

GetThirdPartyCL creates a command line from the flag set. If there are any short form flags, they are resolved using the knownBy map, which the client provides, mapping long form flag names to their short form. The client can choose to compose a command line consisting of all available flags or just the ones changed by the user (ie, they are explicitly specified on the command line as opposed to be defaulted).

Types

type AcceptableEnumValues

type AcceptableEnumValues[E ~int] map[E][]string

AcceptableEnumValues maps values of enum type to an array of string values that are acceptable to be interpreted as that enum value. E is the int based pseudo enum type.

This type allows multiple string values to be taken as equivalent values. The rationale behind this, is for ease of use for the end user. The code can use long winded expressive enum names, without imposing the burden of requiring the user to have to exactly type in that long enum name. Eg an enum value of XmlFormatEn is not end user friendly, we wouldn't them to have to type that in the command line. "xml", or even just "x" would be much easier, but we couldn't really use those names as enum values in code, because they are too generic. This is where AcceptableEnumValues comes in. It provides a mapping from user friendly names to internal enum names, eg, we want to define an acceptable values collection for our predefined output format enum: 'OutputFormatEnum' as follows:

given:

type OutputFormatEnum int const (

  _ OutputFormatEnum = iota
	 XmlFormatEn
	 JsonFormatEn
	 TextFormatEn
	 ScribbleFormatEn)

we can define our acceptables as follows:

AcceptableEnumValues[OutputFormatEnum]{
	 XmlFormatEn:      []string{"xml", "x"},
	 JsonFormatEn:     []string{"json", "j"},
	 TextFormatEn:     []string{"text", "tx"},
	 ScribbleFormatEn: []string{"scribble", "scribbler", "scr"}}

Note, when composing the list of acceptable string values for an enum, it is recommended to make the first item to be the most expressive (ie the longest string value), because whenever an enum needs to be printed, the client can use the 'NameOf' method to display the useful name of the enum rather than getting the integer value, which is not very expressive but is what you get by default using the %v formatter for print functions.

type CobraCommandSpec

type CobraCommandSpec struct {
	// Command: a pointer to the underlying cobra command
	//
	Command *cobra.Command
}

CobraCommandSpec is a wrapper around the cobra command, require to register multiple commands at he same time, see MustRegisterCommands.

type CobraContainer

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

CobraContainer is a wrapper around the collection of cobra commands. Please see unit tests for examples of how to use the CobraContainer.

func NewCobraContainer

func NewCobraContainer(root *cobra.Command) *CobraContainer

NewCobraContainer is a factory function for the CobraContainer. The client must pass in the root Cobra command.

- root: the root Cobra command.

func (*CobraContainer) Command

func (container *CobraContainer) Command(name string) *cobra.Command

Command returns the command registered with the name specified

- name: the name of the Cobra command to check. The name can be derived by calling the Name() function on the cobra command.

Returns the command identified by the name, nil if the command does not exist.

func (*CobraContainer) IsPresent

func (container *CobraContainer) IsPresent(name string) bool

IsPresent checks whether a command has been registered anywhere within the command tree. NB, the container stores all commands in a flat hierarchy as opposed to Cobra which stores commands in a tree like hierarchy.

- name: the name of the command to check.

Returns true if present, false otherwise.

func (*CobraContainer) MustGetParamSet

func (container *CobraContainer) MustGetParamSet(name string) any

MustGetParamSet like Native, except that it returns the parameter set wrapper. The client must perform a type assertion on the returned pointer to translate it back into the native type, ie MustGetParamSet[N] (as opposed to N).

func (*CobraContainer) MustRegisterCommand

func (container *CobraContainer) MustRegisterCommand(parent string, command *cobra.Command)

MustRegisterCommand stores a command inside the container. The client passes in the name of the parent command and the command is added to that parent.

- parent: the name of the parent command. The name can be derived by calling the Name() member function of the Cobra command.

- command: the Cobra command to register.

panics if the there is no command currently registered with the name of parent.

func (*CobraContainer) MustRegisterCommands

func (container *CobraContainer) MustRegisterCommands(parent string, specs ...*CobraCommandSpec)

MustRegisterCommands invokes MustRegisterCommand for each command in the list.

func (*CobraContainer) MustRegisterParamSet

func (container *CobraContainer) MustRegisterParamSet(name string, ps any)

MustRegisterParamSet stores the parameter set under the provided name. Used to reduce the number of floating global variables that the client needs to manage when using cobra.

panics if param set already registered, or attempt to register with an inappropriate type.

func (*CobraContainer) MustRegisterRootedCommand

func (container *CobraContainer) MustRegisterRootedCommand(command *cobra.Command)

MustRegisterRootedCommand stores a command inside the container as a direct descendent of the root Cobra command and is added to the root command itself.

- command: the Cobra command to register.

panics if the command with the same name has already been registered.

func (*CobraContainer) Native

func (container *CobraContainer) Native(name string) any

Native retrieves the Native parameter set that was previously registered.

func (*CobraContainer) Root

func (container *CobraContainer) Root() *cobra.Command

Root returns the root command.

type CrossFieldValidator

type CrossFieldValidator[N any] func(native *N) error

CrossFieldValidator is a client function that is the callback passed into ParamSet.CrossValidate. Should be done after all parsed values have been bound and individually validated.

type DurationOptionValidator

type DurationOptionValidator GenericOptionValidatorWrapper[time.Duration]

DurationOptionValidator defines the struct that wraps the client defined validator function DurationValidatorFn for time.Duration type. This is the instance that is returned by validated binder function BindValidatedDuration.

func (DurationOptionValidator) GetFlag added in v0.3.0

func (validator DurationOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for time.Duration type.

func (DurationOptionValidator) Validate

func (validator DurationOptionValidator) Validate() error

Validate invokes the client defined validator function for time.Duration type.

type DurationSliceOptionValidator

type DurationSliceOptionValidator GenericOptionValidatorWrapper[[]time.Duration]

DurationSliceOptionValidator wraps the client defined validator function for type []time.Duration.

func (DurationSliceOptionValidator) GetFlag added in v0.3.0

func (validator DurationSliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []time.Duration type.

func (DurationSliceOptionValidator) Validate

func (validator DurationSliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []time.Duration type.

type DurationSliceValidatorFn

type DurationSliceValidatorFn func([]time.Duration, *pflag.Flag) error

DurationSliceOptionValidator defines the validator function for DurationSlice type.

type DurationValidatorFn

type DurationValidatorFn func(time.Duration, *pflag.Flag) error

DurationValidatorFn defines the validator function for time.Duration type.

type EnumInfo

type EnumInfo[E ~int] struct {
	// contains filtered or unexported fields
}

EnumInfo represents the meta data for a pseudo int based enum type.

func NewEnumInfo

func NewEnumInfo[E ~int](acceptables AcceptableEnumValues[E]) *EnumInfo[E]

NewEnumInfo is the factory function that creates an EnumInfo instance given a client defined acceptable values collection. Builds the reverse lookup which then allows the client to lookup the enum value for a string. AcceptableEnumValues is defined from enum => slice of acceptables, because the literal representation of this is less verbose than defining the mapping the other way around, ie from acceptable-value => enum, as this would require multiple entries for each enum value. When we defined it as acceptable-value => enum, we can group together the acceptables values into a string array and thus is more concise.

The generic variable E represents the int based enum type, so given:

type OutputFormatEnum int const (

XmlFormatEn OutputFormatEnum = iota + 1
JsonFormatEn
TextFormatEn
ScribbleFormatEn)

... the user should define an EnumInfo for it as:

EnumInfo[OutputFormatEnum].

func (*EnumInfo[E]) Acceptable added in v0.3.0

func (info *EnumInfo[E]) Acceptable() string

Acceptable returns a string that indicates the set of acceptable values for this enum. Since the client can create multiple values for a single enum value, the client can choose whether they want all possible values or just the primary value for each enum entry. The client should use this method if all values for all enumerations in this enum info should be represented in the returned string. This method (and AcceptablePrimes) are typically used to prompt the end user of the acceptable values for an enum based option in a cli application.

func (*EnumInfo[E]) AcceptablePrimes added in v0.3.0

func (info *EnumInfo[E]) AcceptablePrimes() string

AcceptablePrimes returns a string that indicates the set of acceptable values for this enum. Similar to Acceptable except that the returned string only indicates the primary entry for each enumeration in the enum info.

func (*EnumInfo[E]) En

func (info *EnumInfo[E]) En(value string) E

En, returns the underlying int based enum associated with the provided string value as defined by the Acceptables.

func (*EnumInfo[E]) IsValid

func (info *EnumInfo[E]) IsValid(value string) bool

IsValid returns true if the string is an acceptable value for this enum false otherwise.

func (*EnumInfo[E]) IsValidOrEmpty

func (info *EnumInfo[E]) IsValidOrEmpty(value string) bool

IsValidOrEmpty returns true if the string is an acceptable value for this enum or the empty string false otherwise.

func (*EnumInfo[E]) NameOf

func (info *EnumInfo[E]) NameOf(enum E) string

NameOf returns the first acceptable name for the enum value specified. Ideally, there would be a way in go reflection to obtain the name of a variable (as opposed to type name), but this isn't possible. Go reflection currently can only query type names not variable or function names, so the NameOf method is used as a workaround.

func (*EnumInfo[E]) NewSlice

func (info *EnumInfo[E]) NewSlice() EnumSlice[E]

NewSlice creates a new EnumSlice associated with this EnumInfo.

func (*EnumInfo[E]) NewValue

func (info *EnumInfo[E]) NewValue() EnumValue[E]

NewValue creates a new EnumValue associated with this EnumInfo.

func (*EnumInfo[E]) NewWith added in v0.3.0

func (info *EnumInfo[E]) NewWith(value string) EnumValue[E]

NewValue creates new enum value initialised with the provided string value

func (*EnumInfo[E]) String

func (info *EnumInfo[E]) String() string

String returns a string representing contents of all acceptable values for the enum.

type EnumOptionValidator

type EnumOptionValidator GenericOptionValidatorWrapper[string]

EnumOptionValidator defines the struct that wraps the client defined validator function EnumValidatorFn for enum type. This is the instance that is returned by validated binder function BindValidatedEnum.

type EnumSlice

type EnumSlice[E ~int] struct {
	// Info is the EnumInfo associated with this enum value
	//
	Info *EnumInfo[E]

	// The address of Source should be used with BindEnum. The reason why we
	// need an alternative for the 'to' parameter on the binder method is that
	// the associated native member is going to be the pseudo enum type, which
	// is not compatible with the string value that the user provides on the
	// command line. So Source is just a temporary place holder for the value,
	// which subsequently needs to be converted and injected into the native
	// parameter set(see Value() method)
	//
	Source []string
}

EnumSlice represents a collection of EnumValues. Note that this abstraction is not the same as defining a slice of EnumValues, ie []EnumValues.

func (*EnumSlice[E]) AllAreValid

func (es *EnumSlice[E]) AllAreValid() bool

AllAreValid returns true if the Source strings are all acceptable values for this enum false otherwise.

func (*EnumSlice[E]) AllAreValidOrEmpty

func (es *EnumSlice[E]) AllAreValidOrEmpty() bool

AllAreValidOrEmpty returns true if the Source strings are all acceptable values for this enum or the empty string false otherwise.

func (*EnumSlice[E]) Values

func (es *EnumSlice[E]) Values() []E

Values, returns an an array of int based enum values replicating the slice of string values stored in Source.

type EnumValidatorFn

type EnumValidatorFn func(string, *pflag.Flag) error

EnumValidatorFn defines the validator function for enum type.

type EnumValue

type EnumValue[E ~int] struct {
	// Info is the EnumInfo associated with this enum value
	//
	Info *EnumInfo[E]

	// The address of Source should be used with BindEnum. The reason why we
	// need an alternative for the 'to' parameter on the binder method is that
	// the associated native member is going to be the pseudo enum type, which
	// is not compatible with the string value that the user provides on the
	// command line. So Source is just a temporary place holder for the value,
	// which subsequently needs to be converted and injected into the native
	// parameter set(see Value() method)
	//
	Source string
}

func (*EnumValue[E]) IsValid

func (ev *EnumValue[E]) IsValid() bool

IsValid returns true if the string is an acceptable value for this enum false otherwise.

func (*EnumValue[E]) IsValidOrEmpty

func (ev *EnumValue[E]) IsValidOrEmpty() bool

IsValidOrEmpty returns true if the string is an acceptable value for this enum or the empty string false otherwise.

func (*EnumValue[E]) String

func (ev *EnumValue[E]) String() string

String returns the content of Source, assuming it is a valid acceptable enum value. If not valid or not set yet causes panic. As it currently stands, the client needs to validate incoming input as performed in a binder operation.

func (*EnumValue[E]) Value

func (ev *EnumValue[E]) Value() E

Value, returns the value of the enum that is stored within the EnumValue captured from the command line.

type FlagInfo

type FlagInfo struct {
	// Name of flag derived from the Usage
	//
	Name string

	// Usage provides a description of the flag, the first word should eb the name
	// of the flag.
	//
	Usage string

	// Short is the 1 letter character shortcut for the flag.
	//
	Short string

	// Default is the default value for the flag if the user does not provide a
	// value.
	//
	Default any

	// AlternativeFlagSet defines the flag set to use. Allows the user to specify which flag
	// to define this flag on. By default, it is on command.Flags()
	//
	AlternativeFlagSet *pflag.FlagSet

	// Validator is a function that will be used to validate a flag's associated option
	// value.
	//
	Validator StringValidatorFn
}

FlagInfo collates together the parameters passed into the bind methods The Bind methods are just a wrapper around invoking the type based methods on the cobra flag set in order to define flags.

func NewFlagInfo

func NewFlagInfo(usage, short string, def any) *FlagInfo

NewFlagInfo factory function for FlagInfo. Use this function if the flag is to be defined on the default flag set, ie the one on command.Flags().

func NewFlagInfoOnFlagSet

func NewFlagInfoOnFlagSet(usage, short string, def any, alternativeFlagSet *pflag.FlagSet) *FlagInfo

NewFlagInfoOnFlagSet factory function for FlagInfo, with an alternative flag set. This function need only be usd to enable defining flags on the flag set other than that of command.Flags(), eg command.PersistentFlags().

func (*FlagInfo) FlagName

func (info *FlagInfo) FlagName() string

FlagName returns the name of the flag derived from the Usage.

type Float32OptionValidator

type Float32OptionValidator GenericOptionValidatorWrapper[float32]

Float32OptionValidator defines the struct that wraps the client defined validator function Float32ValidatorFn for float32 type. This is the instance that is returned by validated binder function BindValidatedFloat32.

func (Float32OptionValidator) GetFlag added in v0.3.0

func (validator Float32OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for float32 type.

func (Float32OptionValidator) Validate

func (validator Float32OptionValidator) Validate() error

Validate invokes the client defined validator function for float32 type.

type Float32SliceOptionValidator

type Float32SliceOptionValidator GenericOptionValidatorWrapper[[]float32]

Float32SliceOptionValidator wraps the client defined validator function for type []float32.

func (Float32SliceOptionValidator) GetFlag added in v0.3.0

func (validator Float32SliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []float32 type.

func (Float32SliceOptionValidator) Validate

func (validator Float32SliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []float32 type.

type Float32SliceValidatorFn

type Float32SliceValidatorFn func([]float32, *pflag.Flag) error

Float32SliceOptionValidator defines the validator function for Float32Slice type.

type Float32ValidatorFn

type Float32ValidatorFn func(float32, *pflag.Flag) error

Float32ValidatorFn defines the validator function for float32 type.

type Float64OptionValidator

type Float64OptionValidator GenericOptionValidatorWrapper[float64]

Float64OptionValidator defines the struct that wraps the client defined validator function Float64ValidatorFn for float64 type. This is the instance that is returned by validated binder function BindValidatedFloat64.

func (Float64OptionValidator) GetFlag added in v0.3.0

func (validator Float64OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for float64 type.

func (Float64OptionValidator) Validate

func (validator Float64OptionValidator) Validate() error

Validate invokes the client defined validator function for float64 type.

type Float64SliceOptionValidator

type Float64SliceOptionValidator GenericOptionValidatorWrapper[[]float64]

Float64SliceOptionValidator wraps the client defined validator function for type []float64.

func (Float64SliceOptionValidator) GetFlag added in v0.3.0

func (validator Float64SliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []float64 type.

func (Float64SliceOptionValidator) Validate

func (validator Float64SliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []float64 type.

type Float64SliceValidatorFn

type Float64SliceValidatorFn func([]float64, *pflag.Flag) error

Float64SliceOptionValidator defines the validator function for Float64Slice type.

type Float64ValidatorFn

type Float64ValidatorFn func(float64, *pflag.Flag) error

Float64ValidatorFn defines the validator function for float64 type.

type GenericOptionValidatorWrapper

type GenericOptionValidatorWrapper[T any] struct {
	Fn    func(T, *pflag.Flag) error
	Value *T
	Flag  *pflag.Flag
}

Needed because its not possible to create a type safe heterogeneous collection of objects that would be required for the ValidatorContainer.

func (GenericOptionValidatorWrapper[T]) GetFlag added in v0.3.0

func (validator GenericOptionValidatorWrapper[T]) GetFlag() *pflag.Flag

func (GenericOptionValidatorWrapper[T]) Validate

func (validator GenericOptionValidatorWrapper[T]) Validate() error

type IPMaskOptionValidator

type IPMaskOptionValidator GenericOptionValidatorWrapper[net.IPMask]

IPMaskOptionValidator defines the struct that wraps the client defined validator function IPMaskValidatorFn for net.IPMask type. This is the instance that is returned by validated binder function BindValidatedIPMask.

func (IPMaskOptionValidator) GetFlag added in v0.3.0

func (validator IPMaskOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for net.IPMask type.

func (IPMaskOptionValidator) Validate

func (validator IPMaskOptionValidator) Validate() error

Validate invokes the client defined validator function for net.IPMask type.

type IPMaskValidatorFn

type IPMaskValidatorFn func(net.IPMask, *pflag.Flag) error

IPMaskValidatorFn defines the validator function for net.IPMask type.

type IPNetOptionValidator

type IPNetOptionValidator GenericOptionValidatorWrapper[net.IPNet]

IPNetOptionValidator defines the struct that wraps the client defined validator function IPNetValidatorFn for net.IPNet type. This is the instance that is returned by validated binder function BindValidatedIPNet.

func (IPNetOptionValidator) GetFlag added in v0.3.0

func (validator IPNetOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for net.IPNet type.

func (IPNetOptionValidator) Validate

func (validator IPNetOptionValidator) Validate() error

Validate invokes the client defined validator function for net.IPNet type.

type IPNetValidatorFn

type IPNetValidatorFn func(net.IPNet, *pflag.Flag) error

IPNetValidatorFn defines the validator function for net.IPNet type.

type Int16OptionValidator

type Int16OptionValidator GenericOptionValidatorWrapper[int16]

Int16OptionValidator defines the struct that wraps the client defined validator function Int16ValidatorFn for int16 type. This is the instance that is returned by validated binder function BindValidatedInt16.

func (Int16OptionValidator) GetFlag added in v0.3.0

func (validator Int16OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for int16 type.

func (Int16OptionValidator) Validate

func (validator Int16OptionValidator) Validate() error

Validate invokes the client defined validator function for int16 type.

type Int16ValidatorFn

type Int16ValidatorFn func(int16, *pflag.Flag) error

Int16ValidatorFn defines the validator function for int16 type.

type Int32OptionValidator

type Int32OptionValidator GenericOptionValidatorWrapper[int32]

Int32OptionValidator defines the struct that wraps the client defined validator function Int32ValidatorFn for int32 type. This is the instance that is returned by validated binder function BindValidatedInt32.

func (Int32OptionValidator) GetFlag added in v0.3.0

func (validator Int32OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for int32 type.

func (Int32OptionValidator) Validate

func (validator Int32OptionValidator) Validate() error

Validate invokes the client defined validator function for int32 type.

type Int32SliceOptionValidator

type Int32SliceOptionValidator GenericOptionValidatorWrapper[[]int32]

Int32SliceOptionValidator wraps the client defined validator function for type []int32.

func (Int32SliceOptionValidator) GetFlag added in v0.3.0

func (validator Int32SliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []int32 type.

func (Int32SliceOptionValidator) Validate

func (validator Int32SliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []int32 type.

type Int32SliceValidatorFn

type Int32SliceValidatorFn func([]int32, *pflag.Flag) error

Int32SliceOptionValidator defines the validator function for Int32Slice type.

type Int32ValidatorFn

type Int32ValidatorFn func(int32, *pflag.Flag) error

Int32ValidatorFn defines the validator function for int32 type.

type Int64OptionValidator

type Int64OptionValidator GenericOptionValidatorWrapper[int64]

Int64OptionValidator defines the struct that wraps the client defined validator function Int64ValidatorFn for int64 type. This is the instance that is returned by validated binder function BindValidatedInt64.

func (Int64OptionValidator) GetFlag added in v0.3.0

func (validator Int64OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for int64 type.

func (Int64OptionValidator) Validate

func (validator Int64OptionValidator) Validate() error

Validate invokes the client defined validator function for int64 type.

type Int64SliceOptionValidator

type Int64SliceOptionValidator GenericOptionValidatorWrapper[[]int64]

Int64SliceOptionValidator wraps the client defined validator function for type []int64.

func (Int64SliceOptionValidator) GetFlag added in v0.3.0

func (validator Int64SliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []int64 type.

func (Int64SliceOptionValidator) Validate

func (validator Int64SliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []int64 type.

type Int64SliceValidatorFn

type Int64SliceValidatorFn func([]int64, *pflag.Flag) error

Int64SliceOptionValidator defines the validator function for Int64Slice type.

type Int64ValidatorFn

type Int64ValidatorFn func(int64, *pflag.Flag) error

Int64ValidatorFn defines the validator function for int64 type.

type Int8OptionValidator

type Int8OptionValidator GenericOptionValidatorWrapper[int8]

Int8OptionValidator defines the struct that wraps the client defined validator function Int8ValidatorFn for int8 type. This is the instance that is returned by validated binder function BindValidatedInt8.

func (Int8OptionValidator) GetFlag added in v0.3.0

func (validator Int8OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for int8 type.

func (Int8OptionValidator) Validate

func (validator Int8OptionValidator) Validate() error

Validate invokes the client defined validator function for int8 type.

type Int8ValidatorFn

type Int8ValidatorFn func(int8, *pflag.Flag) error

Int8ValidatorFn defines the validator function for int8 type.

type IntOptionValidator

type IntOptionValidator GenericOptionValidatorWrapper[int]

IntOptionValidator defines the struct that wraps the client defined validator function IntValidatorFn for int type. This is the instance that is returned by validated binder function BindValidatedInt.

func (IntOptionValidator) GetFlag added in v0.3.0

func (validator IntOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for int type.

func (IntOptionValidator) Validate

func (validator IntOptionValidator) Validate() error

Validate invokes the client defined validator function for int type.

type IntSliceOptionValidator

type IntSliceOptionValidator GenericOptionValidatorWrapper[[]int]

IntSliceOptionValidator wraps the client defined validator function for type []int.

func (IntSliceOptionValidator) GetFlag added in v0.3.0

func (validator IntSliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []int type.

func (IntSliceOptionValidator) Validate

func (validator IntSliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []int type.

type IntSliceValidatorFn

type IntSliceValidatorFn func([]int, *pflag.Flag) error

IntSliceOptionValidator defines the validator function for IntSlice type.

type IntValidatorFn

type IntValidatorFn func(int, *pflag.Flag) error

IntValidatorFn defines the validator function for int type.

type OptionValidator

type OptionValidator interface {
	Validate() error
	GetFlag() *pflag.Flag
}

OptionValidator wraps the user defined option validator function. This is the instance that is returned from the validated binder methods on the ParamSet.

type ParamSet

type ParamSet[N any] struct {

	// Native is the native client defined parameter set instance, which
	// must be a struct.
	//
	Native *N

	// FlagSet is the default Cobra FlagSet
	//
	FlagSet *pflag.FlagSet

	// Command is the cobra command that the parameter set is bound to.
	//
	Command *cobra.Command
	// contains filtered or unexported fields
}

ParamSet represents a set of flags/options/positional args for a command. The term 'parameter set' is used really to distinguish from other established abstractions (flags/options/positional args, otherwise to be referred to as inputs). The ParamSet is used to ensure that all these inputs are collated into a single entity that the application can refer to as required. A command can have multiple parameter sets associated with it, but will probably best be used with a single parameter set, where inputs not provided by the end user are defaulted, perhaps from config. If its essential to distinguish between different activation scenarios (ie which set of parameters that the user provides) then the client can define multiple parameter sets to reflect this.

The binder methods are defined explicitly for each type as 'go' does not allow for generic parameters defined at the method level as opposed to being defined on the receiver struct.

The generic parameter N represents the client defined native parameter set. Eg:

type WidgetParameterSet struct {
	 Directory string
	 Output    string
	 Format    OutputFormatEnum
	 Shape     InfexionShapeEnum
	 Concise   bool
	 Strategy  TraversalStrategyEnum
	 Overwrite bool
	 Pattern   string}

... is known as the 'native' parameter set for a 'widget' command which would be used to instantiate ParamSet in a declaration as follows:

var paramSet *ParamSet[WidgetParameterSet].

func NewParamSet

func NewParamSet[N any](command *cobra.Command) (ps *ParamSet[N])

NewParamSet is the factory function, which creates a 'parameter set' for a command. Each command can have multiple command sets, reflecting the different ways a command can be used

paramSet = NewParamSet[WidgetParameterSet](widgetCommand)

The default flag set is defined, ie command.Flags(). If an alternative flag set is required, then the client should use

The generic parameter N represents the client defined native parameter set.

func (*ParamSet[N]) BindBool

func (params *ParamSet[N]) BindBool(info *FlagInfo, to *bool) *ParamSet[N]

BindBool binds bool slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindBoolSlice

func (params *ParamSet[N]) BindBoolSlice(info *FlagInfo, to *[]bool) *ParamSet[N]

BindBoolSlice binds []bool slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindDuration

func (params *ParamSet[N]) BindDuration(info *FlagInfo, to *time.Duration) *ParamSet[N]

BindDuration binds time.Duration slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindDurationSlice

func (params *ParamSet[N]) BindDurationSlice(info *FlagInfo, to *[]time.Duration) *ParamSet[N]

BindDurationSlice binds []time.Duration slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindEnum

func (params *ParamSet[N]) BindEnum(info *FlagInfo, to *string) *ParamSet[N]

BindEnum binds enum slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

Note that normally the client would bind to a member of the native parameter set. However, since there is a discrepancy between the type of the native int based pseudo enum member and the equivalent acceptable string value typed by the user on the command line (idiomatically stored on the enum info), the client needs to extract the enum value from the enum info, something like this:

paramSet.Native.Format = OutputFormatEnumInfo.Value()

The best place to put this would be inside the PreRun/PreRunE function, assuming the param set and the enum info are both in scope. Actually, every int based enum flag, would need to have this assignment performed.

func (*ParamSet[N]) BindFloat32

func (params *ParamSet[N]) BindFloat32(info *FlagInfo, to *float32) *ParamSet[N]

BindFloat32 binds float32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindFloat32Slice

func (params *ParamSet[N]) BindFloat32Slice(info *FlagInfo, to *[]float32) *ParamSet[N]

BindFloat32Slice binds []float32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindFloat64

func (params *ParamSet[N]) BindFloat64(info *FlagInfo, to *float64) *ParamSet[N]

BindFloat64 binds float64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindFloat64Slice

func (params *ParamSet[N]) BindFloat64Slice(info *FlagInfo, to *[]float64) *ParamSet[N]

BindFloat64Slice binds []float64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindIPMask

func (params *ParamSet[N]) BindIPMask(info *FlagInfo, to *net.IPMask) *ParamSet[N]

BindIPMask binds net.IPMask slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindIPNet

func (params *ParamSet[N]) BindIPNet(info *FlagInfo, to *net.IPNet) *ParamSet[N]

BindIPNet binds net.IPNet slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt

func (params *ParamSet[N]) BindInt(info *FlagInfo, to *int) *ParamSet[N]

BindInt binds int slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt16

func (params *ParamSet[N]) BindInt16(info *FlagInfo, to *int16) *ParamSet[N]

BindInt16 binds int16 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt32

func (params *ParamSet[N]) BindInt32(info *FlagInfo, to *int32) *ParamSet[N]

BindInt32 binds int32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt32Slice

func (params *ParamSet[N]) BindInt32Slice(info *FlagInfo, to *[]int32) *ParamSet[N]

BindInt32Slice binds []int32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt64

func (params *ParamSet[N]) BindInt64(info *FlagInfo, to *int64) *ParamSet[N]

BindInt64 binds int64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt64Slice

func (params *ParamSet[N]) BindInt64Slice(info *FlagInfo, to *[]int64) *ParamSet[N]

BindInt64Slice binds []int64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindInt8

func (params *ParamSet[N]) BindInt8(info *FlagInfo, to *int8) *ParamSet[N]

BindInt8 binds int8 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindIntSlice

func (params *ParamSet[N]) BindIntSlice(info *FlagInfo, to *[]int) *ParamSet[N]

BindIntSlice binds []int slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindString

func (params *ParamSet[N]) BindString(info *FlagInfo, to *string) *ParamSet[N]

BindString binds string slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindStringSlice

func (params *ParamSet[N]) BindStringSlice(info *FlagInfo, to *[]string) *ParamSet[N]

BindStringSlice binds []string slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindUint

func (params *ParamSet[N]) BindUint(info *FlagInfo, to *uint) *ParamSet[N]

BindUint binds uint slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindUint16

func (params *ParamSet[N]) BindUint16(info *FlagInfo, to *uint16) *ParamSet[N]

BindUint16 binds uint16 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindUint32

func (params *ParamSet[N]) BindUint32(info *FlagInfo, to *uint32) *ParamSet[N]

BindUint32 binds uint32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindUint64

func (params *ParamSet[N]) BindUint64(info *FlagInfo, to *uint64) *ParamSet[N]

BindUint64 binds uint64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindUint8

func (params *ParamSet[N]) BindUint8(info *FlagInfo, to *uint8) *ParamSet[N]

BindUint8 binds uint8 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindUintSlice

func (params *ParamSet[N]) BindUintSlice(info *FlagInfo, to *[]uint) *ParamSet[N]

BindUintSlice binds []uint slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name.

func (*ParamSet[N]) BindValidatedContainsDuration

func (params *ParamSet[N]) BindValidatedContainsDuration(info *FlagInfo, to *time.Duration, collection []time.Duration) OptionValidator

BindValidatedContainsDuration is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsEnum

func (params *ParamSet[N]) BindValidatedContainsEnum(info *FlagInfo, to *string, collection []string) OptionValidator

BindValidatedContainsEnum is an alternative to using BindValidatedEnum. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsFloat32

func (params *ParamSet[N]) BindValidatedContainsFloat32(info *FlagInfo, to *float32, collection []float32) OptionValidator

BindValidatedContainsFloat32 is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsFloat64

func (params *ParamSet[N]) BindValidatedContainsFloat64(info *FlagInfo, to *float64, collection []float64) OptionValidator

BindValidatedContainsFloat64 is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsInt

func (params *ParamSet[N]) BindValidatedContainsInt(info *FlagInfo, to *int, collection []int) OptionValidator

BindValidatedContainsInt is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsInt16

func (params *ParamSet[N]) BindValidatedContainsInt16(info *FlagInfo, to *int16, collection []int16) OptionValidator

BindValidatedContainsInt16 is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsInt32

func (params *ParamSet[N]) BindValidatedContainsInt32(info *FlagInfo, to *int32, collection []int32) OptionValidator

BindValidatedContainsInt32 is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsInt64

func (params *ParamSet[N]) BindValidatedContainsInt64(info *FlagInfo, to *int64, collection []int64) OptionValidator

BindValidatedContainsInt64 is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsInt8

func (params *ParamSet[N]) BindValidatedContainsInt8(info *FlagInfo, to *int8, collection []int8) OptionValidator

BindValidatedContainsInt8 is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsString

func (params *ParamSet[N]) BindValidatedContainsString(info *FlagInfo, to *string, collection []string) OptionValidator

BindValidatedContainsString is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsUint

func (params *ParamSet[N]) BindValidatedContainsUint(info *FlagInfo, to *uint, collection []uint) OptionValidator

BindValidatedContainsUint is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsUint16

func (params *ParamSet[N]) BindValidatedContainsUint16(info *FlagInfo, to *uint16, collection []uint16) OptionValidator

BindValidatedContainsUint16 is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsUint32

func (params *ParamSet[N]) BindValidatedContainsUint32(info *FlagInfo, to *uint32, collection []uint32) OptionValidator

BindValidatedContainsUint32 is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsUint64

func (params *ParamSet[N]) BindValidatedContainsUint64(info *FlagInfo, to *uint64, collection []uint64) OptionValidator

BindValidatedContainsUint64 is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedContainsUint8

func (params *ParamSet[N]) BindValidatedContainsUint8(info *FlagInfo, to *uint8, collection []uint8) OptionValidator

BindValidatedContainsUint8 is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method fails validation if the option value is not a member of the 'collection' slice.

func (*ParamSet[N]) BindValidatedDuration

func (params *ParamSet[N]) BindValidatedDuration(info *FlagInfo, to *time.Duration, validator DurationValidatorFn) OptionValidator

BindValidatedDuration binds time.Duration slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of time.Duration type.

func (*ParamSet[N]) BindValidatedDurationAtLeast

func (params *ParamSet[N]) BindValidatedDurationAtLeast(info *FlagInfo, to *time.Duration, threshold time.Duration) OptionValidator

BindValidatedDurationAtLeast is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedDurationAtMost

func (params *ParamSet[N]) BindValidatedDurationAtMost(info *FlagInfo, to *time.Duration, threshold time.Duration) OptionValidator

BindValidatedDurationAtMost is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedDurationGreaterThan

func (params *ParamSet[N]) BindValidatedDurationGreaterThan(info *FlagInfo, to *time.Duration, threshold time.Duration) OptionValidator

BindValidatedDurationGreaterThan is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedDurationLessThan

func (params *ParamSet[N]) BindValidatedDurationLessThan(info *FlagInfo, to *time.Duration, threshold time.Duration) OptionValidator

BindValidatedDurationLessThan is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedDurationNotWithin

func (params *ParamSet[N]) BindValidatedDurationNotWithin(info *FlagInfo, to *time.Duration, low, high time.Duration) OptionValidator

BindValidatedDurationNotWithin is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedDurationWithin'.

func (*ParamSet[N]) BindValidatedDurationSlice

func (params *ParamSet[N]) BindValidatedDurationSlice(info *FlagInfo, to *[]time.Duration, validator DurationSliceValidatorFn) OptionValidator

BindValidatedDurationSlice binds []time.Duration slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []time.Duration type.

func (*ParamSet[N]) BindValidatedDurationWithin

func (params *ParamSet[N]) BindValidatedDurationWithin(info *FlagInfo, to *time.Duration, low, high time.Duration) OptionValidator

BindValidatedDurationWithin is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedEnum

func (params *ParamSet[N]) BindValidatedEnum(info *FlagInfo, to *string, validator EnumValidatorFn) OptionValidator

BindValidatedEnum binds enum slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of enum type.

Custom enum types created via the generic 'EnumInfo'/'EnumValue' come with a 'IsValid' method. The client can utilise this method inside a custom function passed into 'BindValidatedEnum'. The implementation would simply call this method, either on the EnumInfo or the EnumValue. Please see the readme for more details.

func (*ParamSet[N]) BindValidatedFloat32

func (params *ParamSet[N]) BindValidatedFloat32(info *FlagInfo, to *float32, validator Float32ValidatorFn) OptionValidator

BindValidatedFloat32 binds float32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of float32 type.

func (*ParamSet[N]) BindValidatedFloat32AtLeast

func (params *ParamSet[N]) BindValidatedFloat32AtLeast(info *FlagInfo, to *float32, threshold float32) OptionValidator

BindValidatedFloat32AtLeast is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedFloat32AtMost

func (params *ParamSet[N]) BindValidatedFloat32AtMost(info *FlagInfo, to *float32, threshold float32) OptionValidator

BindValidatedFloat32AtMost is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedFloat32GreaterThan

func (params *ParamSet[N]) BindValidatedFloat32GreaterThan(info *FlagInfo, to *float32, threshold float32) OptionValidator

BindValidatedFloat32GreaterThan is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedFloat32LessThan

func (params *ParamSet[N]) BindValidatedFloat32LessThan(info *FlagInfo, to *float32, threshold float32) OptionValidator

BindValidatedFloat32LessThan is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedFloat32NotWithin

func (params *ParamSet[N]) BindValidatedFloat32NotWithin(info *FlagInfo, to *float32, low, high float32) OptionValidator

BindValidatedFloat32NotWithin is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedFloat32Within'.

func (*ParamSet[N]) BindValidatedFloat32Slice

func (params *ParamSet[N]) BindValidatedFloat32Slice(info *FlagInfo, to *[]float32, validator Float32SliceValidatorFn) OptionValidator

BindValidatedFloat32Slice binds []float32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []float32 type.

func (*ParamSet[N]) BindValidatedFloat32Within

func (params *ParamSet[N]) BindValidatedFloat32Within(info *FlagInfo, to *float32, low, high float32) OptionValidator

BindValidatedFloat32Within is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedFloat64

func (params *ParamSet[N]) BindValidatedFloat64(info *FlagInfo, to *float64, validator Float64ValidatorFn) OptionValidator

BindValidatedFloat64 binds float64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of float64 type.

func (*ParamSet[N]) BindValidatedFloat64AtLeast

func (params *ParamSet[N]) BindValidatedFloat64AtLeast(info *FlagInfo, to *float64, threshold float64) OptionValidator

BindValidatedFloat64AtLeast is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedFloat64AtMost

func (params *ParamSet[N]) BindValidatedFloat64AtMost(info *FlagInfo, to *float64, threshold float64) OptionValidator

BindValidatedFloat64AtMost is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedFloat64GreaterThan

func (params *ParamSet[N]) BindValidatedFloat64GreaterThan(info *FlagInfo, to *float64, threshold float64) OptionValidator

BindValidatedFloat64GreaterThan is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedFloat64LessThan

func (params *ParamSet[N]) BindValidatedFloat64LessThan(info *FlagInfo, to *float64, threshold float64) OptionValidator

BindValidatedFloat64LessThan is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedFloat64NotWithin

func (params *ParamSet[N]) BindValidatedFloat64NotWithin(info *FlagInfo, to *float64, low, high float64) OptionValidator

BindValidatedFloat64NotWithin is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedFloat64Within'.

func (*ParamSet[N]) BindValidatedFloat64Slice

func (params *ParamSet[N]) BindValidatedFloat64Slice(info *FlagInfo, to *[]float64, validator Float64SliceValidatorFn) OptionValidator

BindValidatedFloat64Slice binds []float64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []float64 type.

func (*ParamSet[N]) BindValidatedFloat64Within

func (params *ParamSet[N]) BindValidatedFloat64Within(info *FlagInfo, to *float64, low, high float64) OptionValidator

BindValidatedFloat64Within is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedIPMask

func (params *ParamSet[N]) BindValidatedIPMask(info *FlagInfo, to *net.IPMask, validator IPMaskValidatorFn) OptionValidator

BindValidatedIPMask binds net.IPMask slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of net.IPMask type.

func (*ParamSet[N]) BindValidatedIPNet

func (params *ParamSet[N]) BindValidatedIPNet(info *FlagInfo, to *net.IPNet, validator IPNetValidatorFn) OptionValidator

BindValidatedIPNet binds net.IPNet slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of net.IPNet type.

func (*ParamSet[N]) BindValidatedInt

func (params *ParamSet[N]) BindValidatedInt(info *FlagInfo, to *int, validator IntValidatorFn) OptionValidator

BindValidatedInt binds int slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of int type.

func (*ParamSet[N]) BindValidatedInt16

func (params *ParamSet[N]) BindValidatedInt16(info *FlagInfo, to *int16, validator Int16ValidatorFn) OptionValidator

BindValidatedInt16 binds int16 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of int16 type.

func (*ParamSet[N]) BindValidatedInt16AtLeast

func (params *ParamSet[N]) BindValidatedInt16AtLeast(info *FlagInfo, to *int16, threshold int16) OptionValidator

BindValidatedInt16AtLeast is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt16AtMost

func (params *ParamSet[N]) BindValidatedInt16AtMost(info *FlagInfo, to *int16, threshold int16) OptionValidator

BindValidatedInt16AtMost is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt16GreaterThan

func (params *ParamSet[N]) BindValidatedInt16GreaterThan(info *FlagInfo, to *int16, threshold int16) OptionValidator

BindValidatedInt16GreaterThan is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedInt16LessThan

func (params *ParamSet[N]) BindValidatedInt16LessThan(info *FlagInfo, to *int16, threshold int16) OptionValidator

BindValidatedInt16LessThan is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedInt16NotWithin

func (params *ParamSet[N]) BindValidatedInt16NotWithin(info *FlagInfo, to *int16, low, high int16) OptionValidator

BindValidatedInt16NotWithin is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedInt16Within'.

func (*ParamSet[N]) BindValidatedInt16Within

func (params *ParamSet[N]) BindValidatedInt16Within(info *FlagInfo, to *int16, low, high int16) OptionValidator

BindValidatedInt16Within is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedInt32

func (params *ParamSet[N]) BindValidatedInt32(info *FlagInfo, to *int32, validator Int32ValidatorFn) OptionValidator

BindValidatedInt32 binds int32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of int32 type.

func (*ParamSet[N]) BindValidatedInt32AtLeast

func (params *ParamSet[N]) BindValidatedInt32AtLeast(info *FlagInfo, to *int32, threshold int32) OptionValidator

BindValidatedInt32AtLeast is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt32AtMost

func (params *ParamSet[N]) BindValidatedInt32AtMost(info *FlagInfo, to *int32, threshold int32) OptionValidator

BindValidatedInt32AtMost is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt32GreaterThan

func (params *ParamSet[N]) BindValidatedInt32GreaterThan(info *FlagInfo, to *int32, threshold int32) OptionValidator

BindValidatedInt32GreaterThan is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedInt32LessThan

func (params *ParamSet[N]) BindValidatedInt32LessThan(info *FlagInfo, to *int32, threshold int32) OptionValidator

BindValidatedInt32LessThan is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedInt32NotWithin

func (params *ParamSet[N]) BindValidatedInt32NotWithin(info *FlagInfo, to *int32, low, high int32) OptionValidator

BindValidatedInt32NotWithin is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedInt32Within'.

func (*ParamSet[N]) BindValidatedInt32Slice

func (params *ParamSet[N]) BindValidatedInt32Slice(info *FlagInfo, to *[]int32, validator Int32SliceValidatorFn) OptionValidator

BindValidatedInt32Slice binds []int32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []int32 type.

func (*ParamSet[N]) BindValidatedInt32Within

func (params *ParamSet[N]) BindValidatedInt32Within(info *FlagInfo, to *int32, low, high int32) OptionValidator

BindValidatedInt32Within is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedInt64

func (params *ParamSet[N]) BindValidatedInt64(info *FlagInfo, to *int64, validator Int64ValidatorFn) OptionValidator

BindValidatedInt64 binds int64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of int64 type.

func (*ParamSet[N]) BindValidatedInt64AtLeast

func (params *ParamSet[N]) BindValidatedInt64AtLeast(info *FlagInfo, to *int64, threshold int64) OptionValidator

BindValidatedInt64AtLeast is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt64AtMost

func (params *ParamSet[N]) BindValidatedInt64AtMost(info *FlagInfo, to *int64, threshold int64) OptionValidator

BindValidatedInt64AtMost is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt64GreaterThan

func (params *ParamSet[N]) BindValidatedInt64GreaterThan(info *FlagInfo, to *int64, threshold int64) OptionValidator

BindValidatedInt64GreaterThan is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedInt64LessThan

func (params *ParamSet[N]) BindValidatedInt64LessThan(info *FlagInfo, to *int64, threshold int64) OptionValidator

BindValidatedInt64LessThan is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedInt64NotWithin

func (params *ParamSet[N]) BindValidatedInt64NotWithin(info *FlagInfo, to *int64, low, high int64) OptionValidator

BindValidatedInt64NotWithin is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedInt64Within'.

func (*ParamSet[N]) BindValidatedInt64Slice

func (params *ParamSet[N]) BindValidatedInt64Slice(info *FlagInfo, to *[]int64, validator Int64SliceValidatorFn) OptionValidator

BindValidatedInt64Slice binds []int64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []int64 type.

func (*ParamSet[N]) BindValidatedInt64Within

func (params *ParamSet[N]) BindValidatedInt64Within(info *FlagInfo, to *int64, low, high int64) OptionValidator

BindValidatedInt64Within is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedInt8

func (params *ParamSet[N]) BindValidatedInt8(info *FlagInfo, to *int8, validator Int8ValidatorFn) OptionValidator

BindValidatedInt8 binds int8 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of int8 type.

func (*ParamSet[N]) BindValidatedInt8AtLeast

func (params *ParamSet[N]) BindValidatedInt8AtLeast(info *FlagInfo, to *int8, threshold int8) OptionValidator

BindValidatedInt8AtLeast is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt8AtMost

func (params *ParamSet[N]) BindValidatedInt8AtMost(info *FlagInfo, to *int8, threshold int8) OptionValidator

BindValidatedInt8AtMost is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedInt8GreaterThan

func (params *ParamSet[N]) BindValidatedInt8GreaterThan(info *FlagInfo, to *int8, threshold int8) OptionValidator

BindValidatedInt8GreaterThan is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedInt8LessThan

func (params *ParamSet[N]) BindValidatedInt8LessThan(info *FlagInfo, to *int8, threshold int8) OptionValidator

BindValidatedInt8LessThan is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedInt8NotWithin

func (params *ParamSet[N]) BindValidatedInt8NotWithin(info *FlagInfo, to *int8, low, high int8) OptionValidator

BindValidatedInt8NotWithin is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedInt8Within'.

func (*ParamSet[N]) BindValidatedInt8Within

func (params *ParamSet[N]) BindValidatedInt8Within(info *FlagInfo, to *int8, low, high int8) OptionValidator

BindValidatedInt8Within is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedIntAtLeast

func (params *ParamSet[N]) BindValidatedIntAtLeast(info *FlagInfo, to *int, threshold int) OptionValidator

BindValidatedIntAtLeast is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedIntAtMost

func (params *ParamSet[N]) BindValidatedIntAtMost(info *FlagInfo, to *int, threshold int) OptionValidator

BindValidatedIntAtMost is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedIntGreaterThan

func (params *ParamSet[N]) BindValidatedIntGreaterThan(info *FlagInfo, to *int, threshold int) OptionValidator

BindValidatedIntGreaterThan is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedIntLessThan

func (params *ParamSet[N]) BindValidatedIntLessThan(info *FlagInfo, to *int, threshold int) OptionValidator

BindValidatedIntLessThan is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedIntNotWithin

func (params *ParamSet[N]) BindValidatedIntNotWithin(info *FlagInfo, to *int, low, high int) OptionValidator

BindValidatedIntNotWithin is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedIntWithin'.

func (*ParamSet[N]) BindValidatedIntSlice

func (params *ParamSet[N]) BindValidatedIntSlice(info *FlagInfo, to *[]int, validator IntSliceValidatorFn) OptionValidator

BindValidatedIntSlice binds []int slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []int type.

func (*ParamSet[N]) BindValidatedIntWithin

func (params *ParamSet[N]) BindValidatedIntWithin(info *FlagInfo, to *int, low, high int) OptionValidator

BindValidatedIntWithin is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedNotContainsDuration

func (params *ParamSet[N]) BindValidatedNotContainsDuration(info *FlagInfo, to *time.Duration, collection []time.Duration) OptionValidator

BindValidatedNotContainsDuration is an alternative to using BindValidatedDuration. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsDuration'.

func (*ParamSet[N]) BindValidatedNotContainsEnum

func (params *ParamSet[N]) BindValidatedNotContainsEnum(info *FlagInfo, to *string, collection []string) OptionValidator

BindValidatedNotContainsEnum is an alternative to using BindValidatedEnum. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsEnum'.

func (*ParamSet[N]) BindValidatedNotContainsFloat32

func (params *ParamSet[N]) BindValidatedNotContainsFloat32(info *FlagInfo, to *float32, collection []float32) OptionValidator

BindValidatedNotContainsFloat32 is an alternative to using BindValidatedFloat32. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsFloat32'.

func (*ParamSet[N]) BindValidatedNotContainsFloat64

func (params *ParamSet[N]) BindValidatedNotContainsFloat64(info *FlagInfo, to *float64, collection []float64) OptionValidator

BindValidatedNotContainsFloat64 is an alternative to using BindValidatedFloat64. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsFloat64'.

func (*ParamSet[N]) BindValidatedNotContainsInt

func (params *ParamSet[N]) BindValidatedNotContainsInt(info *FlagInfo, to *int, collection []int) OptionValidator

BindValidatedNotContainsInt is an alternative to using BindValidatedInt. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsInt'.

func (*ParamSet[N]) BindValidatedNotContainsInt16

func (params *ParamSet[N]) BindValidatedNotContainsInt16(info *FlagInfo, to *int16, collection []int16) OptionValidator

BindValidatedNotContainsInt16 is an alternative to using BindValidatedInt16. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsInt16'.

func (*ParamSet[N]) BindValidatedNotContainsInt32

func (params *ParamSet[N]) BindValidatedNotContainsInt32(info *FlagInfo, to *int32, collection []int32) OptionValidator

BindValidatedNotContainsInt32 is an alternative to using BindValidatedInt32. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsInt32'.

func (*ParamSet[N]) BindValidatedNotContainsInt64

func (params *ParamSet[N]) BindValidatedNotContainsInt64(info *FlagInfo, to *int64, collection []int64) OptionValidator

BindValidatedNotContainsInt64 is an alternative to using BindValidatedInt64. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsInt64'.

func (*ParamSet[N]) BindValidatedNotContainsInt8

func (params *ParamSet[N]) BindValidatedNotContainsInt8(info *FlagInfo, to *int8, collection []int8) OptionValidator

BindValidatedNotContainsInt8 is an alternative to using BindValidatedInt8. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsInt8'.

func (*ParamSet[N]) BindValidatedNotContainsString

func (params *ParamSet[N]) BindValidatedNotContainsString(info *FlagInfo, to *string, collection []string) OptionValidator

BindValidatedNotContainsString is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsString'.

func (*ParamSet[N]) BindValidatedNotContainsUint

func (params *ParamSet[N]) BindValidatedNotContainsUint(info *FlagInfo, to *uint, collection []uint) OptionValidator

BindValidatedNotContainsUint is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsUint'.

func (*ParamSet[N]) BindValidatedNotContainsUint16

func (params *ParamSet[N]) BindValidatedNotContainsUint16(info *FlagInfo, to *uint16, collection []uint16) OptionValidator

BindValidatedNotContainsUint16 is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsUint16'.

func (*ParamSet[N]) BindValidatedNotContainsUint32

func (params *ParamSet[N]) BindValidatedNotContainsUint32(info *FlagInfo, to *uint32, collection []uint32) OptionValidator

BindValidatedNotContainsUint32 is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsUint32'.

func (*ParamSet[N]) BindValidatedNotContainsUint64

func (params *ParamSet[N]) BindValidatedNotContainsUint64(info *FlagInfo, to *uint64, collection []uint64) OptionValidator

BindValidatedNotContainsUint64 is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsUint64'.

func (*ParamSet[N]) BindValidatedNotContainsUint8

func (params *ParamSet[N]) BindValidatedNotContainsUint8(info *FlagInfo, to *uint8, collection []uint8) OptionValidator

BindValidatedNotContainsUint8 is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'collection' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedContainsUint8'.

func (*ParamSet[N]) BindValidatedString

func (params *ParamSet[N]) BindValidatedString(info *FlagInfo, to *string, validator StringValidatorFn) OptionValidator

BindValidatedString binds string slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of string type.

func (*ParamSet[N]) BindValidatedStringAtLeast

func (params *ParamSet[N]) BindValidatedStringAtLeast(info *FlagInfo, to *string, threshold string) OptionValidator

BindValidatedStringAtLeast is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedStringAtMost

func (params *ParamSet[N]) BindValidatedStringAtMost(info *FlagInfo, to *string, threshold string) OptionValidator

BindValidatedStringAtMost is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedStringGreaterThan

func (params *ParamSet[N]) BindValidatedStringGreaterThan(info *FlagInfo, to *string, threshold string) OptionValidator

BindValidatedStringGreaterThan is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedStringIsMatch

func (params *ParamSet[N]) BindValidatedStringIsMatch(info *FlagInfo, to *string, pattern string) OptionValidator

BindValidatedStringIsMatch is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'pattern' to utilise predefined functionality as a helper. This method fails validation if the option value does not match the regular expression denoted by 'pattern'.

func (*ParamSet[N]) BindValidatedStringIsNotMatch

func (params *ParamSet[N]) BindValidatedStringIsNotMatch(info *FlagInfo, to *string, pattern string) OptionValidator

BindValidatedStringIsNotMatch is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'pattern' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedStringIsMatch'.

func (*ParamSet[N]) BindValidatedStringLessThan

func (params *ParamSet[N]) BindValidatedStringLessThan(info *FlagInfo, to *string, threshold string) OptionValidator

BindValidatedStringLessThan is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedStringNotWithin

func (params *ParamSet[N]) BindValidatedStringNotWithin(info *FlagInfo, to *string, low, high string) OptionValidator

BindValidatedStringNotWithin is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedStringWithin'.

func (*ParamSet[N]) BindValidatedStringSlice

func (params *ParamSet[N]) BindValidatedStringSlice(info *FlagInfo, to *[]string, validator StringSliceValidatorFn) OptionValidator

BindValidatedStringSlice binds []string slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []string type.

func (*ParamSet[N]) BindValidatedStringWithin

func (params *ParamSet[N]) BindValidatedStringWithin(info *FlagInfo, to *string, low, high string) OptionValidator

BindValidatedStringWithin is an alternative to using BindValidatedString. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedUint

func (params *ParamSet[N]) BindValidatedUint(info *FlagInfo, to *uint, validator UintValidatorFn) OptionValidator

BindValidatedUint binds uint slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of uint type.

func (*ParamSet[N]) BindValidatedUint16

func (params *ParamSet[N]) BindValidatedUint16(info *FlagInfo, to *uint16, validator Uint16ValidatorFn) OptionValidator

BindValidatedUint16 binds uint16 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of uint16 type.

func (*ParamSet[N]) BindValidatedUint16AtLeast

func (params *ParamSet[N]) BindValidatedUint16AtLeast(info *FlagInfo, to *uint16, threshold uint16) OptionValidator

BindValidatedUint16AtLeast is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint16AtMost

func (params *ParamSet[N]) BindValidatedUint16AtMost(info *FlagInfo, to *uint16, threshold uint16) OptionValidator

BindValidatedUint16AtMost is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint16GreaterThan

func (params *ParamSet[N]) BindValidatedUint16GreaterThan(info *FlagInfo, to *uint16, threshold uint16) OptionValidator

BindValidatedUint16GreaterThan is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedUint16LessThan

func (params *ParamSet[N]) BindValidatedUint16LessThan(info *FlagInfo, to *uint16, threshold uint16) OptionValidator

BindValidatedUint16LessThan is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedUint16NotWithin

func (params *ParamSet[N]) BindValidatedUint16NotWithin(info *FlagInfo, to *uint16, low, high uint16) OptionValidator

BindValidatedUint16NotWithin is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedUint16Within'.

func (*ParamSet[N]) BindValidatedUint16Within

func (params *ParamSet[N]) BindValidatedUint16Within(info *FlagInfo, to *uint16, low, high uint16) OptionValidator

BindValidatedUint16Within is an alternative to using BindValidatedUint16. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedUint32

func (params *ParamSet[N]) BindValidatedUint32(info *FlagInfo, to *uint32, validator Uint32ValidatorFn) OptionValidator

BindValidatedUint32 binds uint32 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of uint32 type.

func (*ParamSet[N]) BindValidatedUint32AtLeast

func (params *ParamSet[N]) BindValidatedUint32AtLeast(info *FlagInfo, to *uint32, threshold uint32) OptionValidator

BindValidatedUint32AtLeast is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint32AtMost

func (params *ParamSet[N]) BindValidatedUint32AtMost(info *FlagInfo, to *uint32, threshold uint32) OptionValidator

BindValidatedUint32AtMost is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint32GreaterThan

func (params *ParamSet[N]) BindValidatedUint32GreaterThan(info *FlagInfo, to *uint32, threshold uint32) OptionValidator

BindValidatedUint32GreaterThan is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedUint32LessThan

func (params *ParamSet[N]) BindValidatedUint32LessThan(info *FlagInfo, to *uint32, threshold uint32) OptionValidator

BindValidatedUint32LessThan is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedUint32NotWithin

func (params *ParamSet[N]) BindValidatedUint32NotWithin(info *FlagInfo, to *uint32, low, high uint32) OptionValidator

BindValidatedUint32NotWithin is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedUint32Within'.

func (*ParamSet[N]) BindValidatedUint32Within

func (params *ParamSet[N]) BindValidatedUint32Within(info *FlagInfo, to *uint32, low, high uint32) OptionValidator

BindValidatedUint32Within is an alternative to using BindValidatedUint32. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedUint64

func (params *ParamSet[N]) BindValidatedUint64(info *FlagInfo, to *uint64, validator Uint64ValidatorFn) OptionValidator

BindValidatedUint64 binds uint64 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of uint64 type.

func (*ParamSet[N]) BindValidatedUint64AtLeast

func (params *ParamSet[N]) BindValidatedUint64AtLeast(info *FlagInfo, to *uint64, threshold uint64) OptionValidator

BindValidatedUint64AtLeast is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint64AtMost

func (params *ParamSet[N]) BindValidatedUint64AtMost(info *FlagInfo, to *uint64, threshold uint64) OptionValidator

BindValidatedUint64AtMost is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint64GreaterThan

func (params *ParamSet[N]) BindValidatedUint64GreaterThan(info *FlagInfo, to *uint64, threshold uint64) OptionValidator

BindValidatedUint64GreaterThan is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedUint64LessThan

func (params *ParamSet[N]) BindValidatedUint64LessThan(info *FlagInfo, to *uint64, threshold uint64) OptionValidator

BindValidatedUint64LessThan is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedUint64NotWithin

func (params *ParamSet[N]) BindValidatedUint64NotWithin(info *FlagInfo, to *uint64, low, high uint64) OptionValidator

BindValidatedUint64NotWithin is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedUint64Within'.

func (*ParamSet[N]) BindValidatedUint64Within

func (params *ParamSet[N]) BindValidatedUint64Within(info *FlagInfo, to *uint64, low, high uint64) OptionValidator

BindValidatedUint64Within is an alternative to using BindValidatedUint64. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedUint8

func (params *ParamSet[N]) BindValidatedUint8(info *FlagInfo, to *uint8, validator Uint8ValidatorFn) OptionValidator

BindValidatedUint8 binds uint8 slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of uint8 type.

func (*ParamSet[N]) BindValidatedUint8AtLeast

func (params *ParamSet[N]) BindValidatedUint8AtLeast(info *FlagInfo, to *uint8, threshold uint8) OptionValidator

BindValidatedUint8AtLeast is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint8AtMost

func (params *ParamSet[N]) BindValidatedUint8AtMost(info *FlagInfo, to *uint8, threshold uint8) OptionValidator

BindValidatedUint8AtMost is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUint8GreaterThan

func (params *ParamSet[N]) BindValidatedUint8GreaterThan(info *FlagInfo, to *uint8, threshold uint8) OptionValidator

BindValidatedUint8GreaterThan is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedUint8LessThan

func (params *ParamSet[N]) BindValidatedUint8LessThan(info *FlagInfo, to *uint8, threshold uint8) OptionValidator

BindValidatedUint8LessThan is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedUint8NotWithin

func (params *ParamSet[N]) BindValidatedUint8NotWithin(info *FlagInfo, to *uint8, low, high uint8) OptionValidator

BindValidatedUint8NotWithin is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedUint8Within'.

func (*ParamSet[N]) BindValidatedUint8Within

func (params *ParamSet[N]) BindValidatedUint8Within(info *FlagInfo, to *uint8, low, high uint8) OptionValidator

BindValidatedUint8Within is an alternative to using BindValidatedUint8. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) BindValidatedUintAtLeast

func (params *ParamSet[N]) BindValidatedUintAtLeast(info *FlagInfo, to *uint, threshold uint) OptionValidator

BindValidatedUintAtLeast is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUintAtMost

func (params *ParamSet[N]) BindValidatedUintAtMost(info *FlagInfo, to *uint, threshold uint) OptionValidator

BindValidatedUintAtMost is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than or equal to 'threshold'.

func (*ParamSet[N]) BindValidatedUintGreaterThan

func (params *ParamSet[N]) BindValidatedUintGreaterThan(info *FlagInfo, to *uint, threshold uint) OptionValidator

BindValidatedUintGreaterThan is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably greater than 'threshold'.

func (*ParamSet[N]) BindValidatedUintLessThan

func (params *ParamSet[N]) BindValidatedUintLessThan(info *FlagInfo, to *uint, threshold uint) OptionValidator

BindValidatedUintLessThan is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'threshold' to utilise predefined functionality as a helper. This method fails validation if the option value is not comparably less than 'threshold'.

func (*ParamSet[N]) BindValidatedUintNotWithin

func (params *ParamSet[N]) BindValidatedUintNotWithin(info *FlagInfo, to *uint, low, high uint) OptionValidator

BindValidatedUintNotWithin is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method performs the inverse of 'BindValidatedUintWithin'.

func (*ParamSet[N]) BindValidatedUintSlice

func (params *ParamSet[N]) BindValidatedUintSlice(info *FlagInfo, to *[]uint, validator UintSliceValidatorFn) OptionValidator

BindValidatedUintSlice binds []uint slice flag with a shorthand if 'info.Short' has been set otherwise binds without a short name. Client can provide a function to validate option values of []uint type.

func (*ParamSet[N]) BindValidatedUintWithin

func (params *ParamSet[N]) BindValidatedUintWithin(info *FlagInfo, to *uint, low, high uint) OptionValidator

BindValidatedUintWithin is an alternative to using BindValidatedUint. Instead of providing a function, the client passes in argument(s): 'low, high' to utilise predefined functionality as a helper. This method fails validation if the option value does not lie within 'low' and 'high' (inclusive).

func (*ParamSet[N]) CrossValidate

func (params *ParamSet[N]) CrossValidate(validator CrossFieldValidator[N]) error

CrossValidate provides an optional way to perform cross field validation on the native parameter set. It invokes the client validator function which should be done after all parsed values have been bound and individually validated.

func (*ParamSet[N]) ResolveFlagSet

func (params *ParamSet[N]) ResolveFlagSet(info *FlagInfo) *pflag.FlagSet

ResolveFlagSet resolves between the default flag set on the param set and the optional one defined on the FlagInfo. If there is no default flag set, then there must be one on the flag info, otherwise a panic will occur due dereferencing a nil pointer.

func (*ParamSet[N]) Validate

func (params *ParamSet[N]) Validate() error

Validate invokes all option validators and returns the first error encountered.

func (*ParamSet[N]) Validators

func (params *ParamSet[N]) Validators() *ValidatorContainer

Validators returns the compound validator that the client will need to invoke option validation (Run), typically inside the Run function defined on the cobra command.

type StringOptionValidator

type StringOptionValidator GenericOptionValidatorWrapper[string]

StringOptionValidator defines the struct that wraps the client defined validator function StringValidatorFn for string type. This is the instance that is returned by validated binder function BindValidatedString.

func (StringOptionValidator) GetFlag added in v0.3.0

func (validator StringOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for string type.

func (StringOptionValidator) Validate

func (validator StringOptionValidator) Validate() error

Validate invokes the client defined validator function for string type.

type StringSliceOptionValidator

type StringSliceOptionValidator GenericOptionValidatorWrapper[[]string]

StringSliceOptionValidator wraps the client defined validator function for type []string.

func (StringSliceOptionValidator) GetFlag added in v0.3.0

func (validator StringSliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []string type.

func (StringSliceOptionValidator) Validate

func (validator StringSliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []string type.

type StringSliceValidatorFn

type StringSliceValidatorFn func([]string, *pflag.Flag) error

StringSliceOptionValidator defines the validator function for StringSlice type.

type StringValidatorFn

type StringValidatorFn func(string, *pflag.Flag) error

StringValidatorFn defines the validator function for string type.

type Uint16OptionValidator

type Uint16OptionValidator GenericOptionValidatorWrapper[uint16]

Uint16OptionValidator defines the struct that wraps the client defined validator function Uint16ValidatorFn for uint16 type. This is the instance that is returned by validated binder function BindValidatedUint16.

func (Uint16OptionValidator) GetFlag added in v0.3.0

func (validator Uint16OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for uint16 type.

func (Uint16OptionValidator) Validate

func (validator Uint16OptionValidator) Validate() error

Validate invokes the client defined validator function for uint16 type.

type Uint16ValidatorFn

type Uint16ValidatorFn func(uint16, *pflag.Flag) error

Uint16ValidatorFn defines the validator function for uint16 type.

type Uint32OptionValidator

type Uint32OptionValidator GenericOptionValidatorWrapper[uint32]

Uint32OptionValidator defines the struct that wraps the client defined validator function Uint32ValidatorFn for uint32 type. This is the instance that is returned by validated binder function BindValidatedUint32.

func (Uint32OptionValidator) GetFlag added in v0.3.0

func (validator Uint32OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for uint32 type.

func (Uint32OptionValidator) Validate

func (validator Uint32OptionValidator) Validate() error

Validate invokes the client defined validator function for uint32 type.

type Uint32ValidatorFn

type Uint32ValidatorFn func(uint32, *pflag.Flag) error

Uint32ValidatorFn defines the validator function for uint32 type.

type Uint64OptionValidator

type Uint64OptionValidator GenericOptionValidatorWrapper[uint64]

Uint64OptionValidator defines the struct that wraps the client defined validator function Uint64ValidatorFn for uint64 type. This is the instance that is returned by validated binder function BindValidatedUint64.

func (Uint64OptionValidator) GetFlag added in v0.3.0

func (validator Uint64OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for uint64 type.

func (Uint64OptionValidator) Validate

func (validator Uint64OptionValidator) Validate() error

Validate invokes the client defined validator function for uint64 type.

type Uint64ValidatorFn

type Uint64ValidatorFn func(uint64, *pflag.Flag) error

Uint64ValidatorFn defines the validator function for uint64 type.

type Uint8OptionValidator

type Uint8OptionValidator GenericOptionValidatorWrapper[uint8]

Uint8OptionValidator defines the struct that wraps the client defined validator function Uint8ValidatorFn for uint8 type. This is the instance that is returned by validated binder function BindValidatedUint8.

func (Uint8OptionValidator) GetFlag added in v0.3.0

func (validator Uint8OptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for uint8 type.

func (Uint8OptionValidator) Validate

func (validator Uint8OptionValidator) Validate() error

Validate invokes the client defined validator function for uint8 type.

type Uint8ValidatorFn

type Uint8ValidatorFn func(uint8, *pflag.Flag) error

Uint8ValidatorFn defines the validator function for uint8 type.

type UintOptionValidator

type UintOptionValidator GenericOptionValidatorWrapper[uint]

UintOptionValidator defines the struct that wraps the client defined validator function UintValidatorFn for uint type. This is the instance that is returned by validated binder function BindValidatedUint.

func (UintOptionValidator) GetFlag added in v0.3.0

func (validator UintOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for uint type.

func (UintOptionValidator) Validate

func (validator UintOptionValidator) Validate() error

Validate invokes the client defined validator function for uint type.

type UintSliceOptionValidator

type UintSliceOptionValidator GenericOptionValidatorWrapper[[]uint]

UintSliceOptionValidator wraps the client defined validator function for type []uint.

func (UintSliceOptionValidator) GetFlag added in v0.3.0

func (validator UintSliceOptionValidator) GetFlag() *pflag.Flag

GetFlag returns the flag for []uint type.

func (UintSliceOptionValidator) Validate

func (validator UintSliceOptionValidator) Validate() error

Validate invokes the client defined validator function for []uint type.

type UintSliceValidatorFn

type UintSliceValidatorFn func([]uint, *pflag.Flag) error

UintSliceOptionValidator defines the validator function for UintSlice type.

type UintValidatorFn

type UintValidatorFn func(uint, *pflag.Flag) error

UintValidatorFn defines the validator function for uint type.

type ValidatorCollection

type ValidatorCollection map[string]OptionValidator

type ValidatorContainer

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

ValidatorContainer manages the collection of client defined option validator functions.

func NewValidatorContainer

func NewValidatorContainer(options ...ValidatorContainerOptionFn) *ValidatorContainer

NewValidatorContainer creates an initialised ValidatorContainer instance. To use default behaviour, invoke with no parameters.

func (ValidatorContainer) Add

func (container ValidatorContainer) Add(flag string, validator OptionValidator)

Add adds the validator to the registered set of option validators. Only 1 validator can be registered per flag, a panic will occur if the flag already has a validator registered for it.

func (ValidatorContainer) Get

func (container ValidatorContainer) Get(flag string) OptionValidator

Get returns the option validator for the specified flag, nil if not found.

type ValidatorContainerOptionFn added in v0.2.1

type ValidatorContainerOptionFn func(o *ValidatorContainerOptions)

ValidatorContainerOptionFn definition ofa client defined function to set ValidatorContainer options.

type ValidatorContainerOptions added in v0.2.1

type ValidatorContainerOptions struct {
	// Size internal collection is initialised to
	//
	Size uint
}

ValidatorContainerOptions creation options.

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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