output

package
v2.5.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package output writes *validate.ValidationResult values in text, JSON or YAML form. It is intentionally separate from the parent validate package so that programmatic consumers can depend on validation data without pulling in YAML/JSON encoding dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string

Format names a Renderer. It is a defined string type rather than a bare string so that call sites can use the symbolic constants below (FormatText, FormatJSON, FormatYAML) instead of embedding raw "text"/"json"/"yaml" literals, and so the compiler catches accidental cross-wiring of unrelated string flags.

const (
	// FormatText renders results in human-readable text format with
	// [x], [!], [✓] markers.
	FormatText Format = "text"
	// FormatJSON renders results as JSON.
	FormatJSON Format = "json"
	// FormatYAML renders results as YAML.
	FormatYAML Format = "yaml"
)

Format values.

type Options

type Options struct {
	// SkipSuccessResults suppresses per-resource success lines in text output.
	// It has no effect on JSON or YAML output, where success entries are
	// always part of the structured payload.
	SkipSuccessResults bool
}

Options configures how a validation result is rendered.

type Renderer

type Renderer interface {
	Render(result *pkgvalidate.ValidationResult, w io.Writer, opts Options) error
}

Renderer writes a *ValidationResult to an io.Writer in some specific encoding. Implementations are obtained via RendererFor; the package exposes no other constructors so the supported set is fully closed.

func RendererFor

func RendererFor(format Format) (Renderer, error)

RendererFor returns the Renderer for the given format. The empty string is accepted as FormatText for ergonomics with zero-valued config; any other unrecognised value returns an error. This is the one and only boundary between a format identifier and the typed Renderer dependency that downstream code receives.

Jump to

Keyboard shortcuts

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