Documentation
¶
Index ¶
- Variables
- func NewConflictingTagsError(fieldName string, tags []string, message string) error
- func NewConflictingTypeError(fieldType reflect.Type, fields []string, message string) error
- func NewDuplicateFlagError(flagName, newFieldPath, existingFieldPath string) error
- func NewInputError(inputType, message string) error
- func NewInvalidBooleanTagError(fieldName, tagName, tagValue string) error
- func NewInvalidCompleteHookSignatureError(fieldName, hookName string, err error) error
- func NewInvalidDecodeHookSignatureError(fieldName, hookName string, err error) error
- func NewInvalidDefineHookSignatureError(fieldName, hookName string, err error) error
- func NewInvalidFlagNameError(fieldName, flagName string) error
- func NewInvalidShorthandError(fieldName, shorthand string) error
- func NewInvalidTagUsageError(fieldName, tagName, message string) error
- func NewMissingDecodeHookError(fieldName, hookName string) error
- func NewMissingDefineHookError(fieldName, hookName string) error
- func NewUnsupportedTypeError(fieldName, fieldType, message string) error
- type ConflictingTagsError
- type ConflictingTypeError
- type DefinitionError
- type DuplicateFlagError
- type FlagError
- type FlagErrorKind
- type InputError
- type InvalidBooleanTagError
- type InvalidCompleteHookSignatureError
- type InvalidDecodeHookSignatureError
- type InvalidDefineHookSignatureError
- type InvalidFlagNameError
- type InvalidShorthandError
- type InvalidTagUsageError
- type MissingDecodeHookError
- type MissingDefineHookError
- type UnsupportedTypeError
- type ValidationDetail
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidBooleanTag = errors.New("invalid boolean tag value") ErrInvalidShorthand = errors.New("invalid shorthand flag") ErrMissingDefineHook = errors.New("missing custom flag definition hook") ErrMissingDecodeHook = errors.New("missing custom flag decoding hook") ErrInvalidDefineHookSignature = errors.New("invalid define hook signature") ErrInvalidDecodeHookSignature = errors.New("invalid decode hook signature") ErrInvalidCompleteHookSignature = errors.New("invalid complete hook signature") ErrInvalidTagUsage = errors.New("invalid tag usage") ErrConflictingTags = errors.New("conflicting struct tags") ErrConflictingType = errors.New("conflicting struct field types") ErrUnsupportedType = errors.New("unsupported field type") ErrDuplicateFlag = errors.New("duplicate flag name") ErrInvalidFlagName = errors.New("invalid flag name") )
These are all DefinitionError
var ErrInputValue = errors.New("invalid input value")
Functions ¶
func NewConflictingTagsError ¶
func NewConflictingTypeError ¶
func NewDuplicateFlagError ¶
func NewInputError ¶
NewInputError creates an InputError.
func NewInvalidCompleteHookSignatureError ¶ added in v0.11.0
func NewInvalidFlagNameError ¶
func NewInvalidTagUsageError ¶
func NewUnsupportedTypeError ¶
Types ¶
type ConflictingTagsError ¶
ConflictingTagsError represents conflicting struct tag values
func (*ConflictingTagsError) Error ¶
func (e *ConflictingTagsError) Error() string
func (*ConflictingTagsError) Field ¶
func (e *ConflictingTagsError) Field() string
func (*ConflictingTagsError) Unwrap ¶
func (e *ConflictingTagsError) Unwrap() error
type ConflictingTypeError ¶
type ConflictingTypeError struct {
Type reflect.Type
TypeName string
Fields []string
Message string
}
ConflictingTypeError represents conflicting struct fields having the same custom type
func (*ConflictingTypeError) Error ¶
func (e *ConflictingTypeError) Error() string
func (*ConflictingTypeError) Field ¶
func (e *ConflictingTypeError) Field() string
func (*ConflictingTypeError) Unwrap ¶
func (e *ConflictingTypeError) Unwrap() error
type DefinitionError ¶
DefinitionError represents an error that occurred while processing a struct field's tags at definition time.
type DuplicateFlagError ¶
DuplicateFlagError represents a flag name that is already in use.
func (*DuplicateFlagError) Error ¶
func (e *DuplicateFlagError) Error() string
func (*DuplicateFlagError) Field ¶
func (e *DuplicateFlagError) Field() string
func (*DuplicateFlagError) Unwrap ¶
func (e *DuplicateFlagError) Unwrap() error
type FlagError ¶ added in v0.13.0
type FlagError struct {
FlagName string // the flag name (eg. "port", "level")
Value string // the value that was provided (may be empty for unknown flags)
Kind FlagErrorKind // what kind of flag error
Cause error // the original pflag error
}
FlagError represents a flag parsing error intercepted by [SetupFlagErrors].
It carries only what's needed to identify the error — flag name, bad value, and error kind. Metadata enrichment (expected type, enum values, env vars) happens at classification time in [HandleError], which receives the correct subcommand from [ExecuteC].
func NewFlagError ¶ added in v0.13.0
func NewFlagError(kind FlagErrorKind, flagName, value string, cause error) *FlagError
NewFlagError creates a FlagError.
type FlagErrorKind ¶ added in v0.13.0
type FlagErrorKind int
FlagErrorKind distinguishes between flag error types.
const ( // FlagErrorInvalidValue indicates a flag received a value of the wrong type/format. FlagErrorInvalidValue FlagErrorKind = iota // FlagErrorUnknown indicates the flag does not exist on the command. FlagErrorUnknown )
type InputError ¶
InputError represents an invalid input value for flag definition
func (*InputError) Error ¶
func (e *InputError) Error() string
func (*InputError) Unwrap ¶
func (e *InputError) Unwrap() error
type InvalidBooleanTagError ¶
InvalidBooleanTagError represents an invalid boolean value in struct tags
func (*InvalidBooleanTagError) Error ¶
func (e *InvalidBooleanTagError) Error() string
func (*InvalidBooleanTagError) Field ¶
func (e *InvalidBooleanTagError) Field() string
func (*InvalidBooleanTagError) Unwrap ¶
func (e *InvalidBooleanTagError) Unwrap() error
type InvalidCompleteHookSignatureError ¶ added in v0.11.0
InvalidCompleteHookSignatureError represents an invalid completion hook.
func (*InvalidCompleteHookSignatureError) Error ¶ added in v0.11.0
func (e *InvalidCompleteHookSignatureError) Error() string
func (*InvalidCompleteHookSignatureError) Field ¶ added in v0.11.0
func (e *InvalidCompleteHookSignatureError) Field() string
func (*InvalidCompleteHookSignatureError) Unwrap ¶ added in v0.11.0
func (e *InvalidCompleteHookSignatureError) Unwrap() error
type InvalidDecodeHookSignatureError ¶
InvalidDecodeHookSignatureError represents an invalid custom flag definition hook
func (*InvalidDecodeHookSignatureError) Error ¶
func (e *InvalidDecodeHookSignatureError) Error() string
func (*InvalidDecodeHookSignatureError) Field ¶
func (e *InvalidDecodeHookSignatureError) Field() string
func (*InvalidDecodeHookSignatureError) Unwrap ¶
func (e *InvalidDecodeHookSignatureError) Unwrap() error
type InvalidDefineHookSignatureError ¶
InvalidDefineHookSignatureError represents an invalid custom flag definition hook
func (*InvalidDefineHookSignatureError) Error ¶
func (e *InvalidDefineHookSignatureError) Error() string
func (*InvalidDefineHookSignatureError) Field ¶
func (e *InvalidDefineHookSignatureError) Field() string
func (*InvalidDefineHookSignatureError) Unwrap ¶
func (e *InvalidDefineHookSignatureError) Unwrap() error
type InvalidFlagNameError ¶
InvalidFlagNameError represents an invalid flag name
func (*InvalidFlagNameError) Error ¶
func (e *InvalidFlagNameError) Error() string
func (*InvalidFlagNameError) Field ¶
func (e *InvalidFlagNameError) Field() string
func (*InvalidFlagNameError) Unwrap ¶
func (e *InvalidFlagNameError) Unwrap() error
type InvalidShorthandError ¶
InvalidShorthandError represents an invalid shorthand flag specification
func (*InvalidShorthandError) Error ¶
func (e *InvalidShorthandError) Error() string
func (*InvalidShorthandError) Field ¶
func (e *InvalidShorthandError) Field() string
func (*InvalidShorthandError) Unwrap ¶
func (e *InvalidShorthandError) Unwrap() error
type InvalidTagUsageError ¶
InvalidTagUsageError represents invalid tag usages
func (*InvalidTagUsageError) Error ¶
func (e *InvalidTagUsageError) Error() string
func (*InvalidTagUsageError) Field ¶
func (e *InvalidTagUsageError) Field() string
func (*InvalidTagUsageError) Unwrap ¶
func (e *InvalidTagUsageError) Unwrap() error
type MissingDecodeHookError ¶
MissingDecodeHookError represents a missing custom flag decoding hook
func (*MissingDecodeHookError) Error ¶
func (e *MissingDecodeHookError) Error() string
func (*MissingDecodeHookError) Field ¶
func (e *MissingDecodeHookError) Field() string
func (*MissingDecodeHookError) Unwrap ¶
func (e *MissingDecodeHookError) Unwrap() error
type MissingDefineHookError ¶
MissingDefineHookError represents a missing custom flag definition hook
func (*MissingDefineHookError) Error ¶
func (e *MissingDefineHookError) Error() string
func (*MissingDefineHookError) Field ¶
func (e *MissingDefineHookError) Field() string
func (*MissingDefineHookError) Unwrap ¶
func (e *MissingDefineHookError) Unwrap() error
type UnsupportedTypeError ¶
UnsupportedTypeError represents an unsupported field type
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
func (*UnsupportedTypeError) Field ¶
func (e *UnsupportedTypeError) Field() string
func (*UnsupportedTypeError) Unwrap ¶
func (e *UnsupportedTypeError) Unwrap() error
type ValidationDetail ¶ added in v0.13.0
type ValidationDetail struct {
Field string `json:"field,omitempty"`
StructField string `json:"structField,omitempty"`
Rule string `json:"rule,omitempty"`
Param string `json:"param,omitempty"`
Value any `json:"value,omitempty"`
Message string `json:"message"`
}
ValidationDetail holds structured information extracted from a single validation error.
type ValidationError ¶
ValidationError wraps multiple validation errors that occurred during ValidatableOptions unmarshalling.
func (*ValidationError) Details ¶ added in v0.13.0
func (e *ValidationError) Details() []ValidationDetail
Details extracts structured information from each inner error. For errors implementing fieldErrorInfo (e.g., validator.FieldError), it extracts Field, Rule (tag), Param, and Value. For all other errors, it falls back to populating only the Message field. Returns nil when Errors is nil or empty.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) UnderlyingErrors ¶
func (e *ValidationError) UnderlyingErrors() []error
UnderlyingErrors returns the slice of individual validation errors (immutable).