Documentation
¶
Overview ¶
Package configvalidate provides shared primitives for the `validate` subcommands across vendors: an error collector, line/column resolution from a JSON decoder offset, exit-code conventions, and a tiny Levenshtein helper for closest-match suggestions on unknown enum values (event names, hook types, etc.).
Per-vendor rule sets live in cmd/<vendor>/validate.go.
Index ¶
Constants ¶
const ( ExitOK = 0 ExitErrors = 1 ExitUsageError = 2 )
Exit codes per the validate contract:
- 0: all files passed.
- 1: at least one validation error reported.
- 2: usage error (no flags supplied, file not found, etc.).
Variables ¶
var ErrUsage = errors.New("validate: usage error")
ErrUsage is the sentinel for misuse (no inputs, bad flag values). The caller exits with ExitUsageError and prints usage. Validation rule failures do not use this — they're aggregated into a Collector.
Functions ¶
func ContainsStr ¶
ContainsStr is a small membership helper shared across vendor validate packages. Wraps slices.Contains so callers stay readable at the rule-check sites.
func ExitCode ¶
ExitCode maps the collected issues + caller error to the documented exit codes. usageErr is non-nil when the invocation failed before validation could start (e.g. ErrUsage, file-not-found).
func LineColAt ¶
LineColAt converts a byte offset within data (typically the Offset field on a json.SyntaxError or json.UnmarshalTypeError) into a 1-indexed (line, col). Treats \n as a line break; tabs count as one column. Returns (1, 1) when the offset is at the start.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates Issues from multiple files in a single run. Per the issue spec, the validate subcommand prints every issue rather than first-fail; the caller drives ordering by appending in vendor-specific traversal order. Print sorts by (path, line, col, msg) so output is deterministic.
func (*Collector) Addf ¶
Addf is the printf shorthand for Add — convenient when wiring rules that build the message inline.