Documentation
¶
Overview ¶
Package validationerror provides a shared, dependency-neutral payload and message formatting for structured field/value/reason/suggestion validation errors. Packages such as parser and workflow embed Payload in their own error types so that:
- the message formatting logic (including value truncation) lives in one place and future fixes don't need to be duplicated per package, and
- callers can uniformly detect any structured validation error with errors.As(err, &validationerror.ValidationError) regardless of which package produced it.
Index ¶
Constants ¶
const MaxValueLength = 100
MaxValueLength is the maximum number of characters kept for the Value field when formatting a message with value truncation enabled.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Payload ¶
Payload holds the common field/value/reason/suggestion data shared by structured validation errors across packages.
func (Payload) ValidationField ¶
ValidationField returns the name of the field that failed validation.
func (Payload) ValidationReason ¶
ValidationReason returns the reason validation failed.
func (Payload) ValidationSuggestion ¶
ValidationSuggestion returns actionable remediation guidance, if any.
func (Payload) ValidationValue ¶
ValidationValue returns the offending value, if any.
type ValidationError ¶
type ValidationError interface {
error
ValidationField() string
ValidationValue() string
ValidationReason() string
ValidationSuggestion() string
}
ValidationError is the common interface implemented by structured field/value/reason/suggestion validation errors across packages (for example parser.ValidationError and workflow.WorkflowValidationError). Use errors.As(err, &target) with a variable of this interface type to uniformly extract validation details regardless of the concrete type.