options

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOptions

func ApplyOptions[T any](value *T, opts ...Option[T]) error

ApplyOptions applies a list of options to a value

Types

type Option

type Option[T any] func(*T) error

Option is a function that configures a value T

func WithDefault

func WithDefault[T any, V any](opt Option[T], field *V, defaultValue V) Option[T]

WithDefault sets a default value if the option returns an error

func WithValidation

func WithValidation[T any](opt Option[T], validationFn func(*T) error) Option[T]

WithValidation adds validation to any option

type RequiredFields

type RequiredFields interface {
	ValidateRequiredFields() error
}

RequiredFields is an interface that ensures a type can validate its required fields

Jump to

Keyboard shortcuts

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