predicate

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicPredicate

type AtomicPredicate struct {
	Negated bool         `json:"negated,omitempty"`
	LHS     string       `json:"lhs"`
	Op      ComparisonOp `json:"op"`
	RHS     any          `json:"rhs"`
}

AtomicPredicate compares one observation field with a right-hand value.

func (AtomicPredicate) Evaluate

func (p AtomicPredicate) Evaluate(observation Observation) (bool, error)

func (AtomicPredicate) String

func (p AtomicPredicate) String() string

type BinaryOp

type BinaryOp string

BinaryOp combines two predicates.

const (
	OpAnd BinaryOp = "and"
	OpOr  BinaryOp = "or"
)

type BinaryPredicate

type BinaryPredicate struct {
	LHS Predicate `json:"-"`
	Op  BinaryOp  `json:"op"`
	RHS Predicate `json:"-"`
}

BinaryPredicate combines two predicates with boolean AND or OR.

func (BinaryPredicate) Evaluate

func (p BinaryPredicate) Evaluate(observation Observation) (bool, error)

func (BinaryPredicate) String

func (p BinaryPredicate) String() string

type ComparisonOp

type ComparisonOp string

ComparisonOp is a supported atomic predicate comparison.

const (
	OpEQ  ComparisonOp = "=="
	OpNEQ ComparisonOp = "!="
	OpGT  ComparisonOp = ">"
	OpLT  ComparisonOp = "<"
	OpGTE ComparisonOp = ">="
	OpLTE ComparisonOp = "<="
)

type Observation

type Observation map[string]any

Observation is the default map shape used by predicates.

type Predicate

type Predicate interface {
	Evaluate(observation Observation) (bool, error)
	String() string
}

Predicate evaluates a boolean property over one observation.

type QuantifiedPredicate

type QuantifiedPredicate struct {
	Quantifier Quantifier
	Predicate  Predicate
}

QuantifiedPredicate evaluates a predicate over multiple object observations.

func (QuantifiedPredicate) Evaluate

func (p QuantifiedPredicate) Evaluate(observations []Observation) (bool, error)

func (QuantifiedPredicate) String

func (p QuantifiedPredicate) String() string

type Quantifier

type Quantifier string

Quantifier determines how a predicate is evaluated over a slice of objects.

const (
	QuantifierExists Quantifier = "exist"
	QuantifierAll    Quantifier = "all"
)

Jump to

Keyboard shortcuts

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