repository

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleLoader

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

BundleLoader reads a rule bundle (SchemaPackage JSON) and exposes both the full package and a RuleLoader adapter over its rules. Consumers use LoadPackage to get schema + relations + requires; existing use cases keep working via the RuleLoader methods.

Two constructors:

  • NewJSONBundleLoader(path) loads from a file path
  • NewBytesBundleLoader(data) loads from an in-memory byte slice (for //go:embed use)

Both are stateful: the JSON is parsed once on the first Load call and cached for subsequent lookups.

func NewBytesBundleLoader

func NewBytesBundleLoader(data []byte) *BundleLoader

NewBytesBundleLoader loads a bundle from an in-memory byte slice — the pattern for //go:embed'ed bundles shipped inside a consumer binary.

func NewJSONBundleLoader

func NewJSONBundleLoader(path string) *BundleLoader

NewJSONBundleLoader loads a bundle from a JSON file on disk.

func (*BundleLoader) LoadPackage

func (l *BundleLoader) LoadPackage(ctx context.Context) (*domain.SchemaPackage, error)

LoadPackage returns the full SchemaPackage. Parses the source on first call and caches it; subsequent calls return the same struct.

func (*BundleLoader) LoadRuleByID

func (l *BundleLoader) LoadRuleByID(ctx context.Context, ruleID string) (*domain.Rule, error)

LoadRuleByID satisfies the RuleLoader interface. Looks up an individual rule by ID. Returns ErrRuleNotFound when no rule matches.

func (*BundleLoader) LoadRules

func (l *BundleLoader) LoadRules(ctx context.Context) ([]*domain.Rule, error)

LoadRules satisfies the RuleLoader interface. Returns the bundle's rules; only active rules are surfaced so that consumers don't need to filter separately.

func (*BundleLoader) LoadRulesForTable

func (l *BundleLoader) LoadRulesForTable(ctx context.Context, tableName string) ([]*domain.Rule, error)

LoadRulesForTable satisfies the RuleLoader interface. Filters the bundle's rules to those whose TableName matches. Only active rules are surfaced.

type JSONRuleLoader

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

JSONRuleLoader loads validation rules from JSON files. This adapter implements the RuleLoader interface defined in the usecase layer.

func NewJSONRuleLoader

func NewJSONRuleLoader(filePath string) *JSONRuleLoader

NewJSONRuleLoader creates a new JSON rule loader.

func (*JSONRuleLoader) LoadRuleByID

func (l *JSONRuleLoader) LoadRuleByID(ctx context.Context, ruleID string) (*domain.Rule, error)

LoadRuleByID loads a specific rule by its ID.

func (*JSONRuleLoader) LoadRules

func (l *JSONRuleLoader) LoadRules(ctx context.Context) ([]*domain.Rule, error)

LoadRules loads all rules from the JSON file.

func (*JSONRuleLoader) LoadRulesForTable

func (l *JSONRuleLoader) LoadRulesForTable(ctx context.Context, tableName string) ([]*domain.Rule, error)

LoadRulesForTable loads all rules that apply to a specific table.

Jump to

Keyboard shortcuts

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