Shared payload and formatting helpers for structured validation errors.
The validationerror package centralizes field, value, reason, and suggestion details for validation errors. Packages such as parser and workflow embed Payload in their concrete error types, allowing callers to inspect them uniformly with errors.As and ValidationError.
| Type | Description |
|---|---|
Payload |
Validation details containing the exported Field, Value, Reason, and Suggestion string fields |
ValidationError |
Interface for errors exposing ValidationField, ValidationValue, ValidationReason, and ValidationSuggestion |
| Constant | Type | Value | Description |
|---|---|---|---|
MaxValueLength |
int |
100 |
Maximum value length used by Format when truncation is enabled |
Format always includes the header and reason. It includes the value and suggestion only when they are non-empty. When truncateValue is true, the value is truncated to MaxValueLength.
var validationErr validationerror.ValidationError
if errors.As(err, &validationErr) {
fmt.Printf("%s: %s\n", validationErr.ValidationField(), validationErr.ValidationReason())
}Internal:
pkg/stringutil— value truncation
External:
- None beyond the Go standard library.
This specification is automatically maintained by the spec-extractor workflow.
