validator

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: BSD-2-Clause Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Helpers

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).

type Range

type Range struct {
	Start Position
	End   Position
}

Range describes a range in source file for highlighting.

func NewEmptyRange

func NewEmptyRange() Range

NewEmptyRange creates a placeholder Range.

func RangeFromTree

func RangeFromTree(r tree.Range) Range

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.

Jump to

Keyboard shortcuts

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