validator

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalValidator

type ApprovalValidator struct {
	// contains filtered or unexported fields
}

ApprovalValidator validates that approved nodes have sufficient approvals.

func NewApprovalValidator

func NewApprovalValidator(requiredApprovals int) *ApprovalValidator

NewApprovalValidator creates a new approval validator.

func (*ApprovalValidator) Validate

func (av *ApprovalValidator) Validate(node *domain.Node, collector *errors.Collector)

Validate checks that approved nodes have enough current-version approvals.

type BlockValidator

type BlockValidator struct {
	// contains filtered or unexported fields
}

BlockValidator validates that blocks within content sections have the required fields for their type.

func NewBlockValidator

func NewBlockValidator() *BlockValidator

NewBlockValidator creates a new block validator.

func NewBlockValidatorWithConfig

func NewBlockValidatorWithConfig(customBlockTypes map[string]config.BlockTypeConfig) *BlockValidator

NewBlockValidatorWithConfig creates a block validator with custom type support.

func (*BlockValidator) Validate

func (bv *BlockValidator) Validate(node *domain.Node, collector *errors.Collector)

Validate checks all blocks in a node's content sections.

type ConstraintValidator

type ConstraintValidator struct {
	// contains filtered or unexported fields
}

ConstraintValidator validates CEL expression constraints on nodes.

func NewConstraintValidator

func NewConstraintValidator() *ConstraintValidator

NewConstraintValidator creates a new constraint validator.

func (*ConstraintValidator) Validate

func (cv *ConstraintValidator) Validate(node *domain.Node, allNodes []domain.Node, collector *errors.Collector)

Validate evaluates all constraints on a node. The allNodes parameter is provided for cross-node constraints.

type ContentValidator

type ContentValidator struct{}

ContentValidator validates that approved nodes have content. Draft nodes are allowed to be content-free.

func NewContentValidator

func NewContentValidator() *ContentValidator

NewContentValidator creates a new content validator.

func (*ContentValidator) Validate

func (cv *ContentValidator) Validate(node *domain.Node, collector *errors.Collector)

Validate checks that approved nodes have content with at least one section.

type ContractValidator

type ContractValidator struct {
	// contains filtered or unexported fields
}

ContractValidator validates contract scenarios within nodes. It checks for proper given/when/then structure, valid field types, unique scenario names within each node, and valid node references.

func NewContractValidator

func NewContractValidator() *ContractValidator

NewContractValidator creates a new contract validator.

func (*ContractValidator) Validate

func (cv *ContractValidator) Validate(node *domain.Node, collector *errors.Collector)

Validate checks all contracts in a node for syntax errors. Validations include: - Scenario names are non-empty (E100) - Scenario names are unique within the node (E103) - Steps are non-empty (E101) - At least one step exists in given, when, or then (E104)

func (*ContractValidator) ValidateAll

func (cv *ContractValidator) ValidateAll(nodes []domain.Node, collector *errors.Collector)

ValidateAll checks all contracts across multiple nodes. This includes syntax validation and node reference validation.

type CrossRefValidator

type CrossRefValidator struct {
	// contains filtered or unexported fields
}

CrossRefValidator validates that block fields with ref constraints reference valid values from other block types across all nodes.

func NewCrossRefValidator

func NewCrossRefValidator(customBlockTypes map[string]config.BlockTypeConfig) *CrossRefValidator

NewCrossRefValidator creates a new cross-reference validator.

func (*CrossRefValidator) Validate

func (cv *CrossRefValidator) Validate(nodes []domain.Node, collector *errors.Collector)

Validate runs cross-reference validation across all nodes. Two passes: first collects all reference sets, then validates against them.

type DocValidator

type DocValidator struct{}

DocValidator validates external doc references in nodes and doc blocks.

func NewDocValidator

func NewDocValidator() *DocValidator

NewDocValidator creates a new doc validator.

func (*DocValidator) ValidateDocBlock

func (dv *DocValidator) ValidateDocBlock(block *domain.Block, nodeID, sectionName string, blockIdx int, projectRoot string, collector *errors.Collector)

ValidateDocBlock validates a single doc block's file reference and keywords.

func (*DocValidator) ValidateNodeDocs

func (dv *DocValidator) ValidateNodeDocs(node *domain.Node, projectRoot string, collector *errors.Collector)

ValidateNodeDocs validates all node-level doc references.

type DuplicateIDValidator

type DuplicateIDValidator struct{}

DuplicateIDValidator detects nodes with duplicate IDs.

func NewDuplicateIDValidator

func NewDuplicateIDValidator() *DuplicateIDValidator

NewDuplicateIDValidator creates a new duplicate ID validator.

func (*DuplicateIDValidator) Validate

func (dv *DuplicateIDValidator) Validate(nodes []domain.Node, collector *errors.Collector)

Validate checks for duplicate node IDs across all nodes.

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator coordinates all validators and aggregates errors.

func NewOrchestrator

func NewOrchestrator() *Orchestrator

NewOrchestrator creates a new validator orchestrator.

func NewOrchestratorWithConfig

func NewOrchestratorWithConfig(requiredApprovals int) *Orchestrator

NewOrchestratorWithConfig creates a validator orchestrator with config-based settings.

func NewOrchestratorWithFullConfig

func NewOrchestratorWithFullConfig(requiredApprovals int, customBlockTypes map[string]config.BlockTypeConfig, schemaRules map[string]config.SchemaRuleConfig) *Orchestrator

NewOrchestratorWithFullConfig creates a validator orchestrator with full config support. This includes custom block types, schema rules, and other config-driven validation rules.

func (*Orchestrator) ValidateAll

func (o *Orchestrator) ValidateAll(nodes []domain.Node) *errors.Collector

ValidateAll runs all validators on the provided nodes and returns aggregated errors.

func (*Orchestrator) ValidateAllWithDir

func (o *Orchestrator) ValidateAllWithDir(nodes []domain.Node, rootDir string) *errors.Collector

ValidateAllWithDir runs all validators including unknown field detection. The rootDir is needed to read raw YAML files for unknown field checking.

func (*Orchestrator) ValidateNode

func (o *Orchestrator) ValidateNode(node *domain.Node) *errors.Collector

ValidateNode validates a single node without cross-node checks. This is useful for pre-save validation after patches/rewrites. It runs schema, content, block, and constraint validation but skips reference and duplicate ID checks which require all nodes.

type ReferenceValidator

type ReferenceValidator struct {
	// contains filtered or unexported fields
}

ReferenceValidator validates that all node references resolve to existing nodes.

func NewReferenceValidator

func NewReferenceValidator() *ReferenceValidator

NewReferenceValidator creates a new reference validator.

func (*ReferenceValidator) Validate

func (rv *ReferenceValidator) Validate(nodes []domain.Node, collector *errors.Collector)

Validate checks that all references in nodes resolve correctly. Generates suggestions for broken references that look like typos.

type SchemaRulesValidator

type SchemaRulesValidator struct {
	// contains filtered or unexported fields
}

SchemaRulesValidator validates nodes against per-kind schema rules defined in config.

func NewSchemaRulesValidator

func NewSchemaRulesValidator(rules map[string]config.SchemaRuleConfig) *SchemaRulesValidator

NewSchemaRulesValidator creates a validator with the given per-kind rules.

func (*SchemaRulesValidator) Validate

func (srv *SchemaRulesValidator) Validate(node *domain.Node, collector *errors.Collector)

Validate checks that a node has all required fields for its kind.

type SchemaValidator

type SchemaValidator struct{}

SchemaValidator validates that nodes have all required fields and correct types.

func NewSchemaValidator

func NewSchemaValidator() *SchemaValidator

NewSchemaValidator creates a new schema validator.

func (*SchemaValidator) Validate

func (sv *SchemaValidator) Validate(node *domain.Node, collector *errors.Collector)

Validate checks that a node has all required fields.

type UnknownFieldValidator

type UnknownFieldValidator struct {
	// contains filtered or unexported fields
}

UnknownFieldValidator detects unknown top-level keys in node YAML files. This helps catch typos and prevents silent data loss from misspelled fields.

func NewUnknownFieldValidator

func NewUnknownFieldValidator() *UnknownFieldValidator

NewUnknownFieldValidator creates a new unknown field validator.

func (*UnknownFieldValidator) ValidateDirectory

func (uf *UnknownFieldValidator) ValidateDirectory(rootDir string, collector *errors.Collector)

ValidateDirectory reads all YAML files in a nodes directory and checks for unknown fields.

func (*UnknownFieldValidator) ValidateNestedFields

func (uf *UnknownFieldValidator) ValidateNestedFields(nodeID string, filePath string, rawMap map[string]interface{}, collector *errors.Collector)

ValidateNestedFields checks nested structures in raw YAML for unknown fields. This catches typos like "conext" instead of "context" in refs.uses[] entries.

func (*UnknownFieldValidator) ValidateYAML

func (uf *UnknownFieldValidator) ValidateYAML(nodeID string, filePath string, rawKeys []string, collector *errors.Collector)

ValidateYAML checks a raw YAML map for unknown top-level keys. The nodeID and filePath are used for error reporting.

Jump to

Keyboard shortcuts

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