Documentation
¶
Overview ¶
Package gs_cond provides a set of conditions that can be used for evaluating and combining logical conditions in a flexible way.
Index ¶
- func And(conditions ...gs.Condition) gs.Condition
- func EvalExpr(input string, val interface{}) (bool, error)
- func FormatGroup(op string, conditions []gs.Condition) string
- func None(conditions ...gs.Condition) gs.Condition
- func Not(c gs.Condition) gs.Condition
- func OnBean(s gs.BeanSelectorInterface) gs.Condition
- func OnExpression(expression string) gs.Condition
- func OnFunc(fn gs.CondFunc) gs.Condition
- func OnMissingBean(s gs.BeanSelectorInterface) gs.Condition
- func OnMissingProperty(name string) gs.Condition
- func OnSingleBean(s gs.BeanSelectorInterface) gs.Condition
- func Or(conditions ...gs.Condition) gs.Condition
- func RegisterExpressFunc(name string, fn interface{})
- type OnPropertyInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
And combines multiple conditions with an AND operator, returning true if all conditions are satisfied.
func EvalExpr ¶
EvalExpr evaluates a boolean expression (input) using the provided value (val) and any registered express functions. The string expression to evaluate (should return a boolean value). The value used in the evaluation (referred to as `$` in the expression context).
func FormatGroup ¶
FormatGroup generates a formatted string for a group of conditions (AND, OR, NONE).
func None ¶
None combines multiple conditions with a NONE operator, returning true if none of the conditions are satisfied.
func OnBean ¶
func OnBean(s gs.BeanSelectorInterface) gs.Condition
OnBean creates a condition that evaluates to true if at least one bean matches the provided selector.
func OnExpression ¶
OnExpression creates a condition that evaluates based on a custom string expression. The expression is expected to return true or false.
func OnMissingBean ¶
func OnMissingBean(s gs.BeanSelectorInterface) gs.Condition
OnMissingBean creates a condition that evaluates to true if no beans match the provided selector.
func OnMissingProperty ¶
OnMissingProperty creates a condition that matches if the specified property is missing.
func OnSingleBean ¶
func OnSingleBean(s gs.BeanSelectorInterface) gs.Condition
OnSingleBean creates a condition that evaluates to true if exactly one bean matches the provided selector.
func Or ¶
Or combines multiple conditions with an OR operator, returning true if at least one condition is satisfied.
func RegisterExpressFunc ¶
func RegisterExpressFunc(name string, fn interface{})
RegisterExpressFunc registers an express function with a specified name. The function can later be used in expressions evaluated by EvalExpr.
Types ¶
type OnPropertyInterface ¶
type OnPropertyInterface interface {
gs.Condition
MatchIfMissing() OnPropertyInterface
HavingValue(s string) OnPropertyInterface
}
OnPropertyInterface defines the methods for evaluating a condition based on a property. This interface provides flexibility for matching missing properties and checking their values.
func OnProperty ¶
func OnProperty(name string) OnPropertyInterface
OnProperty creates a condition based on the presence and value of a specified property.