How rules works in in general?

i am trying to use rules but i am not able to figure out what schema in rules is used for ?
i have control named animalName and another control typeOfAnimal based on animalName
“rule”: {
“effect”: “DISABLE”,
“condition”: {
“scope”: “#/properties/animalName”,
“schema”: {
///////////// use of this schema ?
}
}
}

[original thread by Akshay Pilankar]

In schema any JSON schema can be placed. We use it to validate against the data found at the scope path. Either the data matches the schema, then the rule takes effect, or the data doesn’t match the schema, then the opposite effect is applied.

For example, let’s say your schema looks like this:

  type: 'object',
  properties: {
    animalName: {
      type: 'string'
    },
    vegetarian: {
      type: 'boolean'
    }
  }
}

Now let’s say you want to disable the vegetarian option until the name is at least 3 characters long, for this you could use the following rule on the vegetarian control:

    {
      type: 'Control',
      scope: '#/properties/vegetarian',
      rule: {
        effect: 'ENABLE',
        condition: {
          scope: '#/properties/animalName',
          schema: {
            type: 'string',
            minLength: 3
          }
        }
      }
    }

The rule will ENABLE this control when the data at #/properties/animalName is a string with at least a length of 3.

[Akshay Pilankar]

thanks

[Akshay Pilankar]

and can you also tell me if i can add rule to category level