Skip to content

Work backwards from results to matching input object #10

Description

@matthewdfleming

How would you recommend fetching the parts of the evaluated object that triggered a match? I want to be able to iterate over the results of a match and then locate the spot in the object graph that caused the match to be true. This is especially relevant in the one to many case. In the results that come out of the engine, how can I find which child caused the result to be 'true'?

Let's say you have a Parent that has many children and the rule matches when any of the children are named Polo. I'd like to be able to sort out which 'children' matched the rule. In the below case, children id 2 and 3 should be matched.

Rule

{
  "name": "marco_polo",
  "description": "find kids named Polo",
  "conditions": {
    "any": [
        {
          "operator": "equal",
          "value": "Polo",
          "path": "$.Parent.Children[*].Name"
        },
     ]
  }
}

Data

{
  "Parent": {
     "Children": [
        {"Id": 1, "Name": "Marco"},
        {"Id": 2, "Name": "Polo"}
        {"Id": 3, "Name": "Polo"}
      ]   
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions