flag

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 1 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewValidationError

func NewValidationError(flag string, reason error) error

NewValidationError provides a convenient helper function to create flag validation errors usable by run.Config implementations.

Types

type ValidationError

type ValidationError string

ValidationError provides the ability to create constant errors for run.Group validation errors, e.g. incorrect flag values.

const (
	// FlagErr can be used as formatting string for flag related validation
	// errors where the first variable lists the flag name and the second
	// variable is the actual error.
	FlagErr = "--%s error: %w"

	// ErrRequired is returned when required config options are not provided.
	ErrRequired ValidationError = "required"

	// ErrInvalidPath is returned when a path config option is invalid.
	ErrInvalidPath ValidationError = "invalid path"

	// ErrInvalidVal is returned when the value passed into a flag argument is invalid.
	ErrInvalidVal ValidationError = "invalid value"
)

func (ValidationError) Error

func (v ValidationError) Error() string

Error implements the built-in error interface.

Jump to

Keyboard shortcuts

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