validation

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldValidate

func ShouldValidate(filePath string) bool

ShouldValidate checks if a file path should be validated. Returns true for files in ~/.loom/agents/ or ~/.loom/workflows/

Types

type ValidationError

type ValidationError struct {
	Level    ValidationLevel `json:"level"`
	Line     int             `json:"line,omitempty"`     // Line number where error occurred (0 if unknown)
	Field    string          `json:"field,omitempty"`    // Field path (e.g., "spec.tools", "metadata.name")
	Message  string          `json:"message"`            // Human-readable error message
	Fix      string          `json:"fix,omitempty"`      // Suggested fix
	Got      string          `json:"got,omitempty"`      // What was provided
	Expected string          `json:"expected,omitempty"` // What was expected
}

ValidationError represents a single validation issue.

type ValidationLevel

type ValidationLevel string

ValidationLevel represents the level of validation that detected an issue.

const (
	// LevelSyntax indicates a YAML syntax error (parsing failure)
	LevelSyntax ValidationLevel = "SYNTAX"
	// LevelStructure indicates a schema/structure violation (proto compliance)
	LevelStructure ValidationLevel = "STRUCTURE"
	// LevelSemantic indicates a logical consistency issue (missing references, invalid values)
	LevelSemantic ValidationLevel = "SEMANTIC"
)

type ValidationResult

type ValidationResult struct {
	Valid    bool                `json:"valid"`
	Errors   []ValidationError   `json:"errors,omitempty"`
	Warnings []ValidationWarning `json:"warnings,omitempty"`
	Kind     string              `json:"kind,omitempty"` // "Agent" or "Workflow"
	FilePath string              `json:"file_path,omitempty"`
}

ValidationResult contains the complete validation result for a YAML file.

func ValidateYAMLContent

func ValidateYAMLContent(content, filePath string) ValidationResult

ValidateYAMLContent validates YAML content and returns detailed results. filePath is optional (for better error messages).

func ValidateYAMLFile

func ValidateYAMLFile(filePath string) ValidationResult

ValidateYAMLFile validates a YAML file at the given path. Automatically detects if it's an Agent or Workflow based on content.

func (*ValidationResult) ErrorCount

func (r *ValidationResult) ErrorCount() int

ErrorCount returns the total number of errors.

func (*ValidationResult) ErrorsByLevel

func (r *ValidationResult) ErrorsByLevel() map[ValidationLevel][]ValidationError

ErrorsByLevel returns errors grouped by validation level.

func (*ValidationResult) FormatForWeaver

func (r *ValidationResult) FormatForWeaver() string

FormatForWeaver formats the validation result in a human-readable format optimized for LLM consumption (clear structure, actionable fixes).

func (*ValidationResult) HasErrors

func (r *ValidationResult) HasErrors() bool

HasErrors returns true if there are any validation errors.

func (*ValidationResult) HasWarnings

func (r *ValidationResult) HasWarnings() bool

HasWarnings returns true if there are any validation warnings.

type ValidationWarning

type ValidationWarning struct {
	Message string `json:"message"`
	Field   string `json:"field,omitempty"`
	Fix     string `json:"fix,omitempty"`
}

ValidationWarning represents a non-blocking issue that should be reviewed.

Jump to

Keyboard shortcuts

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