rules

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package rules provides an extensible rules engine for normalizing VCTM data. Rules can transform, fix, or validate VCTM documents to ensure compatibility with the latest specification or to handle legacy field names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine manages and applies normalization rules

func NewEmptyEngine

func NewEmptyEngine() *Engine

NewEmptyEngine creates a rules engine without any rules

func NewEngine

func NewEngine() *Engine

NewEngine creates a new rules engine with the default built-in rules

func (*Engine) Apply

func (e *Engine) Apply(data map[string]interface{}) (*Result, error)

Apply runs all enabled rules on the data and returns a summary of changes

func (*Engine) Disable

func (e *Engine) Disable(name string)

Disable prevents a rule from being applied

func (*Engine) Enable

func (e *Engine) Enable(name string)

Enable allows a previously disabled rule to be applied

func (*Engine) Register

func (e *Engine) Register(rule Rule)

Register adds a rule to the engine

func (*Engine) Rules

func (e *Engine) Rules() []Rule

Rules returns all registered rules

func (*Engine) SetVerbose

func (e *Engine) SetVerbose(verbose bool)

SetVerbose enables verbose logging of rule applications

type Result

type Result struct {
	Applied []string // Names of rules that made changes
	Skipped []string // Names of disabled rules
}

Result contains the outcome of applying rules

func (*Result) HasChanges

func (r *Result) HasChanges() bool

HasChanges returns true if any rules made changes

func (*Result) String

func (r *Result) String() string

String returns a human-readable summary

type Rule

type Rule interface {
	// Name returns the unique identifier for this rule
	Name() string

	// Description returns a human-readable description of what the rule does
	Description() string

	// Apply transforms the VCTM data in place and returns true if any changes were made.
	// The rule receives the entire VCTM document as a map for maximum flexibility.
	Apply(data map[string]interface{}) (changed bool, err error)
}

Rule defines the interface for a normalization rule. Rules are applied to VCTM data represented as map[string]interface{} to allow flexible transformation regardless of the source (markdown, JSON, etc.).

func NewRule

func NewRule(name, description string, apply func(map[string]interface{}) (bool, error)) Rule

NewRule creates a rule from a function

type RuleFunc

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

RuleFunc is a convenience type for creating rules from functions

func (*RuleFunc) Apply

func (r *RuleFunc) Apply(data map[string]interface{}) (bool, error)

func (*RuleFunc) Description

func (r *RuleFunc) Description() string

func (*RuleFunc) Name

func (r *RuleFunc) Name() string

Jump to

Keyboard shortcuts

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