Documentation
¶
Overview ¶
Package condeval evaluates dal.Condition trees against record values.
It is the shared, adapter-independent evaluator behind row-level access conditions: a condition is validated once when a policy is compiled (Validate), its parameters are substituted from runtime values (Substitute), and the resolved condition is matched against a record's data (Match). Record data is normalised through a JSON round trip (ToMap), so struct fields are addressed by their JSON names, numbers compare as float64, and times compare as RFC 3339 strings — the same shape the in-memory adapter stores and queries.
The supported subset mirrors the core query model: comparisons of a field reference with a constant, an array (for In) or a parameter, combined with And/Or groups. Anything else is rejected by Validate and reported as an error by Match, never silently treated as a match.
Index ¶
- func ApplyUpdates(data map[string]any, updates []update.Update) error
- func CloneMap(data map[string]any) map[string]any
- func Lookup(data map[string]any, path string) (any, bool)
- func Match(data map[string]any, condition dal.Condition) (bool, error)
- func Substitute(condition dal.Condition, resolve func(name string) (any, bool)) (dal.Condition, error)
- func ToMap(data any) (map[string]any, error)
- type Info
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyUpdates ¶ added in v0.76.0
ApplyUpdates applies field updates to JSON-shaped record data, producing the post-image of an Update: a field name addresses a top-level key, a field path a nested key, and update.DeleteField removes the leaf. Missing intermediate maps are created; an intermediate value that is not a map is an error, because the write would fail or corrupt the record and the policy must not guess the outcome.
func CloneMap ¶ added in v0.76.0
CloneMap deep-copies JSON-shaped record data (maps, slices and scalars) so a post-image can be computed without touching the pre-image.
func Match ¶
Match reports whether data satisfies condition. A nil condition matches. A field the record lacks never satisfies a comparison. A condition outside the supported subset, or one still carrying a parameter, is an error.
func Substitute ¶
func Substitute(condition dal.Condition, resolve func(name string) (any, bool)) (dal.Condition, error)
Substitute returns a copy of condition with every parameter replaced by the value resolve returns for its name: a slice or array becomes a dal.Array, anything else a dal.Constant. An unresolved parameter is an error that names it, so callers can fail closed and explain why.