Documentation
¶
Overview ¶
Package validation provides custom validation rule checking for entities. It encapsulates the logic for evaluating metamodel validation rules against entity sets, supporting scoped validation for view-based analysis.
Index ¶
- func CheckChecklistRule(items []markdown.ChecklistItem, rule *metamodel.ChecklistRule) bool
- func CheckContentRule(content string, rule *metamodel.ContentRule) bool
- func CountBySeverity(violations []Violation) (errors, warnings int)
- type LuaViolation
- type Service
- func (s *Service) Check(entities []*entity.Entity, scope map[string]bool) []Violation
- func (s *Service) CheckRule(rule metamodel.ValidationRule, entities []*entity.Entity, ...) []Violation
- func (s *Service) CheckRules(entities []*entity.Entity, scope, ruleNames map[string]bool) []Violation
- func (s *Service) Rules() []metamodel.ValidationRule
- func (s *Service) WithCache(c *lua.Cache) *Service
- type Violation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckChecklistRule ¶
func CheckChecklistRule(items []markdown.ChecklistItem, rule *metamodel.ChecklistRule) bool
CheckChecklistRule validates checklist items against a metamodel checklist rule. Returns true when items are acceptable (or when rule is nil, or when there are no items).
func CheckContentRule ¶
func CheckContentRule(content string, rule *metamodel.ContentRule) bool
CheckContentRule validates markdown content against a metamodel-defined content rule. Returns true if the content satisfies the rule (or when rule is nil).
func CountBySeverity ¶
CountBySeverity returns counts of errors and warnings from violations.
Types ¶
type LuaViolation ¶
type LuaViolation struct {
Message string // Custom error message (required)
Severity string // "error" or "warning" (optional, defaults to rule's severity)
}
LuaViolation represents a violation returned from a Lua validation script.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service validates entities against custom metamodel rules.
func New ¶
New creates a validation service for the given metamodel. deps provides read-only lua access for rules that use Lua scripts. The ProjectRoot field of deps is used to resolve lua_file paths from validations/. The supplied metamodel is authoritative — it overwrites deps.Meta so the Go-side rule evaluator and the Lua-side filter helpers cannot disagree about which schema is in effect.
func (*Service) Check ¶
Check runs all validation rules against the given entities. If scope is non-nil, only entities in scope are checked.
func (*Service) CheckRule ¶
func (s *Service) CheckRule( rule metamodel.ValidationRule, entities []*entity.Entity, scope map[string]bool, ) []Violation
CheckRule checks a single rule against entities.
func (*Service) CheckRules ¶
func (s *Service) CheckRules(entities []*entity.Entity, scope, ruleNames map[string]bool) []Violation
CheckRules runs validation rules against the given entities. If ruleNames is nil, all rules are run. Otherwise, only rules in the set are run. If scope is non-nil, only entities in scope are checked.
func (*Service) Rules ¶
func (s *Service) Rules() []metamodel.ValidationRule
Rules returns the validation rules from the metamodel.