configutil

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 7 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 ValidateWithSchema

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

ValidateWithSchema validates config against a JSON Schema. The schema parameter is the map[string]any returned by ConfigurableRule.Schema(). 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