UI Rule Syntax for Integers With Math (And Other Type Rules Syntax?)

Hello. I’m trying to track down what’s possible with UI Schema rules for integers, whether I can apply math (integer > 50) to those integer rules (and seen what’s possible with other, undocumented field data type rules.)

I see Rules syntax for integer fields:

"rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/my_boolean_field",
          "schema": {
            "const": 1234
          }
        }
      }

…but I’m not sure if / how I can apply math to this rule?

Rules For Other Data Types
If it’s helpful for others looking for Rules syntax for other data types:

I see Rules syntax for boolean fields:

"rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/my_boolean_field",
          "schema": {
            "const": true
          }
        }
      }

And Rules for enum fields:

"rule": {
  "effect": "SHOW",
  "condition": {
    "scope": "#/properties/my_enum_field",
    "schema": { 
        "enum": ["foo"] 
    }
  }
}

Thanks.

Update: I see more syntax options that might work as limited math workarounds.

Example: trigger a rule if a number / integer field’s value is less than 2000:

"rule": {
  "effect": "SHOW",
  "condition": {
    "scope": "#/properties/my_integer_field",
    "schema": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2000
    }
  }
}

Hi @hellosilver,

We’re using AJV for evaluating the condition.schema. So anything which is expressible via JSON Schema can be used for the rules. JSON Schema is not that expressive when it comes to expressing dependencies between instance values, so it can barely be used for math.

For more expressive rules you can implement custom renderers which are able to evaluate your more custom rules. Besides evaluating your rule they could just forward to the existing renderers, making them easy to implement. If you want to you could also customize AJV and support your custom rules this way.