configutil

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package configutil provides utilities for rule configuration resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coerce

func Coerce[T any](config any, defaults T) T

Coerce converts a dynamic rule config value to a typed config with defaults. Supported inputs:

  • T
  • *T
  • map[string]any (decoded via Resolve)

Any unsupported value falls back to defaults.

func Resolve

func Resolve[T any](opts map[string]any, defaults T) T

Resolve merges user options over defaults and unmarshals to typed config. If opts is nil or empty, returns defaults unchanged. This eliminates duplicated map-to-struct conversion in each rule.

Note: For slice/map fields, only nil values are replaced with defaults. An explicitly empty slice ([]string{}) preserves the empty value, allowing users to explicitly clear defaults.

func RuleSchema added in v0.12.0

func RuleSchema(ruleCode string) (map[string]any, error)

RuleSchema returns the externalized JSON schema map for a rule.

func ValidateRuleOptions added in v0.12.0

func ValidateRuleOptions(ruleCode string, config any) error

ValidateRuleOptions validates rule-specific options using the schema registry.

func ValidateWithSchema

func ValidateWithSchema(config any, schema map[string]any) error

ValidateWithSchema validates config against a JSON Schema map. Returns nil if valid, or an error describing validation failures.

Types

This section is empty.

Jump to

Keyboard shortcuts

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