grules icon indicating copy to clipboard operation
grules copied to clipboard

Allow nested composites

Open becoded opened this issue 6 years ago • 2 comments

Add support to nest composites

becoded avatar Apr 12 '18 12:04 becoded

Thanks for the PR! What use case are you trying to solve with nested composites? Is it something that can be solved with multiple rules potentially?

I have used this package pretty extensively and have not come across this need, so I'm interested to hear your use case.

huttotw avatar Apr 12 '18 15:04 huttotw

Hello @huttotw I'm working on a system that distribute S3 events to multiple queues based on some business rules. Each queue has 3 different priorities. Based on some metadata (origin, amount of pages in a document, ...), type of the file, name of the file and the expected processing priority, the right queue + priority is selected.

I have some business rules that looks like ( ( A && B && C ) || (E && F && ( G || H) ) Or converted to json:

    "composites": [ 
      {
        "operator": "or",
        "composites": [
          {
            "operator": "and",
            "rules": [
              {
                "comparator": "eq",
                "path": "pathToA",
                "value": "A"
              },
              {
                "comparator": "eq",
                "path": "pathToB",
                "value": "B"
              },
              {
                "comparator": "eq",
                "path": "pathToC",
                "value": "C"
              }
            ]
          }, {
            "operator": "and",
            "rules": [
              {
                "comparator": "eq",
                "path": "pathToE",
                "value": "E"
              },
              {
                "comparator": "eq",
                "path": "pathToF",
                "value": "F"
              }
            ],
            "composites": [
              {
                "operator": "or",
                "rules": [
                  {
                    "comparator": "eq",
                    "path": "pathToG",
                    "value": "G"
                  },
                  {
                    "comparator": "eq",
                    "path": "pathToH",
                    "value": "H"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]

becoded avatar Apr 12 '18 16:04 becoded