Documentation
¶
Overview ¶
Package validator defines interfaces and types for configuration validation.
This package provides the contract layer for validation. Concrete implementations live in subpackages (e.g., validators/jsonschema).
Key Types ¶
- Validator validates a tree.Node and returns a slice of ValidationError. It also reports its [Validator.SchemaType].
- ValidationError describes a single validation failure with Path (keypath.KeyPath), Range (source position), Code (machine-readable), and Message (human-readable).
- Position represents a line/column in a source file (1-based, 0 if unknown).
- Range is a start/end Position pair used for source highlighting.
Helpers ¶
- NewEmptyRange creates a placeholder Range when position information is unavailable.
- RangeFromTree converts a tree.Range to a validator Range.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Position ¶
type Position struct {
Line int // Line number (1-based), 0 if unknown.
Column int // Column number (1-based), 0 if unknown.
}
Position describes a position in source file (for LSP integration). Currently placeholder - will be populated when position tracking is implemented.
type Range ¶
Range describes a range in source file for highlighting.
func RangeFromTree ¶
RangeFromTree converts a tree.Range to a validator.Range.
type ValidationError ¶
type ValidationError struct {
Path keypath.KeyPath // Logical path to the field.
Range Range // Physical range (populated when position tracking available).
Code string // Machine-readable code (e.g., "type", "required", "minimum").
Message string // Human-readable description.
}
ValidationError describes a single validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error returns a string representation of the validation error.
type Validator ¶
type Validator interface {
// Validate checks the tree and returns all errors found.
// Returns nil if validation succeeds.
Validate(root *tree.Node) []ValidationError
// SchemaType returns the type identifier (e.g., "json-schema").
SchemaType() string
}
Validator validates configuration against a schema.