Documentation
¶
Index ¶
- type BundleLoader
- func (l *BundleLoader) LoadPackage(ctx context.Context) (*domain.SchemaPackage, error)
- func (l *BundleLoader) LoadRuleByID(ctx context.Context, ruleID string) (*domain.Rule, error)
- func (l *BundleLoader) LoadRules(ctx context.Context) ([]*domain.Rule, error)
- func (l *BundleLoader) LoadRulesForTable(ctx context.Context, tableName string) ([]*domain.Rule, error)
- type JSONRuleLoader
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 ¶
LoadRuleByID satisfies the RuleLoader interface. Looks up an individual rule by ID. Returns ErrRuleNotFound when no rule matches.
func (*BundleLoader) LoadRules ¶
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 ¶
LoadRuleByID loads a specific rule by its ID.
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.