Documentation
¶
Index ¶
- func MarshalCondition[T any](c Condition[T]) (any, error)
- func MarshalConditionAny(c any) (any, error)
- type Condition
- func And[T any](conds ...Condition[T]) Condition[T]
- func Contains[T any](p, val string) Condition[T]
- func ContainsFold[T any](p, val string) Condition[T]
- func ConvertFromCondSurrogate[T any](s any) (Condition[T], error)
- func Defined[T any](p string) Condition[T]
- func EndsWith[T any](p, val string) Condition[T]
- func EndsWithFold[T any](p, val string) Condition[T]
- func Eq[T any](p string, val any) Condition[T]
- func EqFold[T any](p string, val any) Condition[T]
- func EqualField[T any](path1, path2 string) Condition[T]
- func EqualFieldFold[T any](path1, path2 string) Condition[T]
- func Greater[T any](p string, val any) Condition[T]
- func GreaterEqual[T any](p string, val any) Condition[T]
- func GreaterEqualField[T any](path1, path2 string) Condition[T]
- func GreaterField[T any](path1, path2 string) Condition[T]
- func In[T any](p string, values ...any) Condition[T]
- func InFold[T any](p string, values ...any) Condition[T]
- func Less[T any](p string, val any) Condition[T]
- func LessEqual[T any](p string, val any) Condition[T]
- func LessEqualField[T any](path1, path2 string) Condition[T]
- func LessField[T any](path1, path2 string) Condition[T]
- func Log[T any](message string) Condition[T]
- func Matches[T any](p, pattern string) Condition[T]
- func MatchesFold[T any](p, pattern string) Condition[T]
- func Ne[T any](p string, val any) Condition[T]
- func NeFold[T any](p string, val any) Condition[T]
- func Not[T any](c Condition[T]) Condition[T]
- func NotEqualField[T any](path1, path2 string) Condition[T]
- func NotEqualFieldFold[T any](path1, path2 string) Condition[T]
- func Or[T any](conds ...Condition[T]) Condition[T]
- func ParseCondition[T any](expr string) (Condition[T], error)
- func StartsWith[T any](p, val string) Condition[T]
- func StartsWithFold[T any](p, val string) Condition[T]
- func Type[T any](p, typeName string) Condition[T]
- func Undefined[T any](p string) Condition[T]
- func UnmarshalCondition[T any](data []byte) (Condition[T], error)
- type InternalCondition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalCondition ¶
MarshalCondition returns a serializable surrogate (struct or map) for the condition. To get the JSON bytes, pass the result to json.Marshal.
func MarshalConditionAny ¶
Types ¶
type Condition ¶
type Condition[T any] interface { // Evaluate evaluates the condition against the given value. Evaluate(v *T) (bool, error) // MarshalJSON returns the JSON representation of the condition. MarshalJSON() ([]byte, error) InternalCondition }
Condition represents a logical check against a value of type T.
func Contains ¶
Contains returns a condition that checks if the string value at the path contains the given substring.
func ContainsFold ¶
ContainsFold returns a condition that checks if the string value at the path contains the given substring (case-insensitive).
func EndsWith ¶
EndsWith returns a condition that checks if the string value at the path ends with the given suffix.
func EndsWithFold ¶
EndsWithFold returns a condition that checks if the string value at the path ends with the given suffix (case-insensitive).
func EqFold ¶
EqFold returns a condition that checks if the value at the path is equal to the given value (case-insensitive).
func EqualField ¶
EqualField returns a condition that checks if the value at path1 is equal to the value at path2.
func EqualFieldFold ¶
EqualFieldFold returns a condition that checks if the value at path1 is equal to the value at path2 (case-insensitive).
func Greater ¶
Greater returns a condition that checks if the value at the path is greater than the given value.
func GreaterEqual ¶
GreaterEqual returns a condition that checks if the value at the path is greater than or equal to the given value.
func GreaterEqualField ¶
GreaterEqualField returns a condition that checks if the value at path1 is greater than or equal to the value at path2.
func GreaterField ¶
GreaterField returns a condition that checks if the value at path1 is greater than the value at path2.
func InFold ¶
InFold returns a condition that checks if the value at the path is one of the given values (case-insensitive).
func Less ¶
Less returns a condition that checks if the value at the path is less than the given value.
func LessEqual ¶
LessEqual returns a condition that checks if the value at the path is less than or equal to the given value.
func LessEqualField ¶
LessEqualField returns a condition that checks if the value at path1 is less than or equal to the value at path2.
func LessField ¶
LessField returns a condition that checks if the value at path1 is less than the value at path2.
func Matches ¶
Matches returns a condition that checks if the string value at the path matches the given regex pattern.
func MatchesFold ¶
MatchesFold returns a condition that checks if the string value at the path matches the given regex pattern (case-insensitive).
func Ne ¶
Ne returns a condition that checks if the value at the path is not equal to the given value.
func NeFold ¶
NeFold returns a condition that checks if the value at the path is not equal to the given value (case-insensitive).
func NotEqualField ¶
NotEqualField returns a condition that checks if the value at path1 is not equal to the value at path2.
func NotEqualFieldFold ¶
NotEqualFieldFold returns a condition that checks if the value at path1 is not equal to the value at path2 (case-insensitive).
func ParseCondition ¶
ParseCondition parses a string expression into a Condition[T] tree.
func StartsWith ¶
StartsWith returns a condition that checks if the string value at the path starts with the given prefix.
func StartsWithFold ¶
StartsWithFold returns a condition that checks if the string value at the path starts with the given prefix (case-insensitive).
type InternalCondition ¶
type InternalCondition interface {
EvaluateAny(v any) (bool, error)
Paths() []string
WithRelativePath(prefix string) InternalCondition
}
InternalCondition is an internal interface for efficient evaluation without reflection.