settings

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package settings validates declarative inspector fields without losing extensions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(s map[string]any, key string) bool

Read a boolean setting or return false

func Clone

func Clone(value any) any

Clone supported settings values recursively

func Merge

func Merge(global, action map[string]any) map[string]any

Overlay action settings on cloned global defaults

func Number

func Number(s map[string]any, key string, fallback float64) float64

Read a finite numeric setting or use the fallback

func String

func String(s map[string]any, key, fallback string) string

Read a string setting or use the fallback

func Validate

func Validate(fields []Field, input map[string]any) (map[string]any, error)

Validate applies defaults only to absent keys. Null is an explicit value and invalid for known fields; unknown keys are cloned and preserved

Types

type Field

type Field struct {
	PathPicker     string            `json:"path_picker,omitempty"`
	DefaultPresent bool              `json:"-"`
	Key            string            `json:"key"`
	Label          string            `json:"label"`
	Type           string            `json:"type"`
	Default        any               `json:"default,omitempty"`
	Options        []string          `json:"options,omitempty"`
	OptionLabels   map[string]string `json:"option_labels,omitempty"`
	Min            *float64          `json:"min,omitempty"`
	Max            *float64          `json:"max,omitempty"`
	Required       bool              `json:"required,omitempty"`
	// Sensitive masks string fields in inspectors; values remain ordinary strings
	Sensitive bool `json:"sensitive,omitempty"`
}

func (*Field) UnmarshalJSON

func (f *Field) UnmarshalJSON(data []byte) error

UnmarshalJSON distinguishes an absent default from an explicit null default

Jump to

Keyboard shortcuts

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