engine

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NodeDefaultSeerLeaf = "config"

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name      string
	Type      Type
	Required  bool
	Key       bool // means the value is the key of a map
	Default   any
	Path      []StringMatch
	Compat    []StringMatch
	Validator AttributeValidator
}

func Attributes

func Attributes(attrs ...*Attribute) []*Attribute

func Bool

func Bool(name string, options ...Option) *Attribute

func Float

func Float(name string, options ...Option) *Attribute

func Int

func Int(name string, options ...Option) *Attribute

func String

func String(name string, options ...Option) *Attribute

func StringSlice

func StringSlice(name string, options ...Option) *Attribute

type AttributeValidator

type AttributeValidator func(any) error

type Engine

type Engine interface {
	Schema() Schema
	Parse() (object.Object[SeerRef], error)           // load linked to seer
	Process() (object.Object[object.Refrence], error) // load & process
	Dump(obj object.Object[object.Refrence]) error    // dump object to filesystem using engine's seer and sync
}

func New

func New(schema Schema, options ...yaseer.Option) (Engine, error)

type NextValidation

type NextValidation struct {
	Key       string         `json:"key"`       // identifier for the validation (e.g., "domain", "fqdn")
	Value     any            `json:"value"`     // value to validate
	Validator string         `json:"validator"` // validator name (e.g., "dns", "cid")
	Context   map[string]any `json:"context"`   // extra context for validation
}

NextValidation represents a validation that needs to be performed externally. The compiler emits these during compilation, and it's up to the caller to implement and process these validations.

func NewNextValidation

func NewNextValidation(key string, value any, validator string, context map[string]any) NextValidation

NewNextValidation creates a new NextValidation instance.

type Node

type Node struct {
	Group      bool
	Match      StringMatch
	Attributes []*Attribute
	Children   []*Node
}

func Define

func Define(match StringMatch, attrs []*Attribute, children ...*Node) *Node

func DefineGroup

func DefineGroup(match string, children ...*Node) *Node

func DefineIter

func DefineIter(attrs []*Attribute, children ...*Node) *Node

func DefineIterGroup

func DefineIterGroup(attrs []*Attribute, children ...*Node) *Node

func Root

func Root(attrs []*Attribute, children ...*Node) *Node

func (*Node) ChildMatch

func (n *Node) ChildMatch(name string) (*Node, error)

func (*Node) Map

func (n *Node) Map() map[string]any

type ObjectDataType

type ObjectDataType interface {
	object.Refrence | SeerRef
}

type Option

type Option func(*Attribute)

func Compat

func Compat(path ...StringMatch) Option

func Default

func Default[T any](val T) Option

func InSet

func InSet[T string | int | float64](elms ...T) Option

func IsCID

func IsCID() Option

func IsEmail

func IsEmail() Option

func IsFqdn

func IsFqdn() Option

func IsHttpMethod

func IsHttpMethod() Option

func IsVariableName

func IsVariableName() Option

func Key

func Key() Option

func MinInt

func MinInt(min int) Option

MinInt returns an Option that validates an Int attribute is >= min.

func Path

func Path(path ...StringMatch) Option

func Required

func Required() Option

func Validator

func Validator[T any](validator func(T) error) Option

type Schema

type Schema interface {
	Yaml() (string, error)
	Json() (string, error)
	Map() map[string]any
}

func SchemaDefinition

func SchemaDefinition(root *Node) Schema

type SeerOps

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

type SeerRef

type SeerRef *struct {
	object.Object[object.Refrence]
	// contains filtered or unexported fields
}

type StringMatch

type StringMatch any // string or PathMatcher

type StringMatchAll

type StringMatchAll struct{}

func (StringMatchAll) Match

func (StringMatchAll) Match(string) bool

func (StringMatchAll) String

func (StringMatchAll) String() string

type StringMatcher

type StringMatcher interface {
	Match(s string) bool
	String() string
}

func All

func All() StringMatcher

func Either

func Either(values ...string) StringMatcher

type SupportedTypes

type SupportedTypes interface {
	int | bool | float64 | string | []string
}

type Type

type Type int
const (
	TypeInt Type = iota
	TypeBool
	TypeFloat
	TypeString
	TypeStringSlice
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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