Documentation
¶
Overview ¶
Package expression provides expression evaluation and validation adapters.
This package implements the domain ExpressionEvaluator and ExpressionValidator ports using the expr-lang/expr library for safe template expression parsing and evaluation in workflow conditions.
Key Types:
ExprEvaluator - Evaluates boolean and integer expressions in workflow conditions ExprValidator - Compiles and validates expression syntax at workflow load time
Usage Example:
evaluator := expression.NewExprEvaluator()
result, err := evaluator.EvaluateBool("status == 'success'", data)
if err != nil {
// Handle evaluation error
}
// Use result for conditional branching
validator := expression.NewExprValidator()
if err := validator.Compile("count > 10"); err != nil {
// Handle validation error
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewExprEvaluator ¶
func NewExprEvaluator() ports.ExpressionEvaluator
NewExprEvaluator creates a new ExprEvaluator instance.
func NewExprValidator ¶
func NewExprValidator() ports.ExpressionValidator
NewExprValidator creates a new ExprValidator instance.
Types ¶
type ExprEvaluator ¶
type ExprEvaluator struct {
// contains filtered or unexported fields
}
ExprEvaluator implements ports.ExpressionEvaluator using the expr-lang/expr library. Delegates to pkg/expression.ExprEvaluator for context building and evaluation logic.
func (*ExprEvaluator) EvaluateBool ¶
func (e *ExprEvaluator) EvaluateBool(exprStr string, ctx *interpolation.Context) (bool, error)
EvaluateBool evaluates a boolean expression against the provided context. Returns the boolean result of the expression, or an error if evaluation fails.
func (*ExprEvaluator) EvaluateInt ¶
func (e *ExprEvaluator) EvaluateInt(exprStr string, ctx *interpolation.Context) (int, error)
EvaluateInt evaluates an arithmetic expression against the provided context. Returns the integer result of the expression, or an error if evaluation fails. The result is coerced to int type regardless of the underlying numeric type.
type ExprValidator ¶
type ExprValidator struct{}
ExprValidator implements ports.ExpressionValidator using the expr-lang/expr library. Provides expression syntax validation by wrapping expr.Compile().
func (*ExprValidator) Compile ¶
func (v *ExprValidator) Compile(expression string) error
Compile validates the syntax of an expression string. Returns nil if the expression is syntactically valid, error otherwise. Empty or whitespace-only expressions are considered valid (no stop condition).