{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schemas.apps.smartmate.io/tables/filter/filter.schema.json",
  "$$target": "https://schemas.apps.smartmate.io/tables/filter/filter.schema.json",
  "title": "filter",
  "description": "Allows to filter the records of a table.",
  "type": "object",
  "properties": {
    "combinator": {
      "description": "Determines if only one of the rules, or all of them should pass to include a record in the filter results.",
      "type": "string",
      "default": "and",
      "enum": ["and", "or"]
    },
    "not": {
      "description": "Negates the rules",
      "type": "boolean",
      "default": false
    },
    "rules": {
      "description": "Array of rules that should be applied to the filter. It can contain a nested filter as can be seen in the example.",
      "type": "array",
      "items": {
        "oneOf": [
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/filter.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/booleanRule.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/arrayFieldRule.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/numericCollectionRule.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/numericRule.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/objectRule.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/stringCollectionRule.schema.json"},
          {"$ref": "https://schemas.apps.smartmate.io/tables/filter/rules/stringRule.schema.json"}
        ]
      },
      "minItems": 1
    }
  },
  "required": ["rules"],
  "additionalProperties": false
}
