Skip to content

[Proposal] Add rules for framework independent conditional evaluation #1

@Anthropic

Description

@Anthropic

Note: this is incomplete to use as example to kick off discussion
An ability to set options based on conditional logic formatted in a consistent way that can be implemented in all potential framework variations.

I implement this on my server, but something that covers this for both would be useful.

  "readonly": {
    "$$switch": {
      "$$options": [
        {
          "$$when": [ "workflow=/^(new|modify)$/" ],
          "$$then": false
        }
      ],
      "$$else": true
    }
  }

Even allowing RegEx for matching values.

There is also rules as defined in EclipseSource JSONForms as defined here: https://github.com/eclipsesource/jsonforms/blob/master/examples/app/local/local.controller.js#L58

   "rule":{
      "effect":"HIDE",
      "condition":{
         "type":"LEAF" ,
         "scope": {
            "$ref": "#/properties/personalData/properties/age"
         },
         "expectedValue":36
      }
   }

I propose a combination approach that allows a rule to define a set of value changes for the object.

"myfield": {
   "title": "My Field with rules",
   "key": "personalData.myfield",
   "rules": [
      {
         "condition": {
            "scope": { "$ref": "#/properties/personalData/properties/age" },
            "match": 36
         },
         "then": {
            "readonly": true,
            "hide": true,
            "default": 21
         }
      },
      {
         "condition": [
            {
               "scope": { "$ref": "#/properties/personalData/properties/role" },
               "patternMatch": "/^manager$/"
            },
            {
               "scope": { "$state": "access" },
               "match": "Admin"
            }
         ],
         "then": {
            "readonly": false,
            "hide": false,
            "model": 42
         }
      },
   ],
   "else": {
      "readonly": true,
      "hide": true,
      "default": 11
   }
}

All keywords, key, scope etc.. can be defined later...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions