schema

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package schema provides validation for graph data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation failure.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type Validator

type Validator struct {
	// AllowedNodeTypes restricts node types. If empty, all types are allowed.
	AllowedNodeTypes []string

	// AllowedEdgeTypes restricts edge types. If empty, all types are allowed.
	AllowedEdgeTypes []string

	// RequireNodeLabel requires all nodes to have a non-empty label.
	RequireNodeLabel bool
}

Validator validates graph data against schema rules.

func NewValidator

func NewValidator() *Validator

NewValidator creates a validator with default settings.

func (*Validator) ValidateEdge

func (v *Validator) ValidateEdge(e *graph.Edge) error

ValidateEdge validates a single edge.

func (*Validator) ValidateEdgeRefs

func (v *Validator) ValidateEdgeRefs(e *graph.Edge, nodes map[string]*graph.Node) error

ValidateEdgeRefs validates that edge references exist in the node set.

func (*Validator) ValidateGraph

func (v *Validator) ValidateGraph(g *graph.Graph) []error

ValidateGraph validates an entire graph.

func (*Validator) ValidateNode

func (v *Validator) ValidateNode(n *graph.Node) error

ValidateNode validates a single node.

Jump to

Keyboard shortcuts

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