{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/datagalaxy/json-schema/datagalaxy-rule-schema.json",
  "title": "Rule",
  "description": "Data quality rule.",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/datagalaxy-openapi.yml#/components/schemas/Rule",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique rule identifier. Example: ec64748c-059e-4a6a-a9db-5f9e634a2da8",
      "format": "guid"
    },
    "entityId": {
      "type": "string",
      "description": "Entity unique identifier (composed of the workspace UUID and the object UUID separated by a colon). Example: bd95bbbf-16f8-4618-ab47-4ee835563304:52e35910-c3d0-45ce-b330-a9db28e5dc73"
    },
    "code": {
      "type": [
        "string",
        "null"
      ],
      "description": "External identifier of the rule. Example: 123_client_code_unique"
    },
    "clientId": {
      "type": "string",
      "description": "Client unique identifier",
      "format": "guid"
    },
    "creationTime": {
      "type": "string",
      "description": "Creation date",
      "format": "date-time"
    },
    "userId": {
      "type": "string",
      "description": "User unique identifier (creator)",
      "format": "guid"
    },
    "statement": {
      "type": "string",
      "description": "Statement of the rule in natural language. Example: Client code must be unique"
    },
    "fieldIds": {
      "type": "array",
      "description": "A list of ReferenceId in string format",
      "items": {
        "type": "string"
      }
    },
    "type": {
      "description": "Rule type",
      "nullable": true,
      "oneOf": [
        {
          "$ref": "#/$defs/RuleTypeEnum"
        }
      ]
    },
    "lastChecks": {
      "type": "array",
      "description": "Last checks",
      "items": {
        "$ref": "#/$defs/RuleCheck"
      }
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "description": "Description"
    },
    "severity": {
      "description": "Severity level",
      "nullable": true,
      "oneOf": [
        {
          "$ref": "#/$defs/SeverityEnum"
        }
      ]
    },
    "category": {
      "type": [
        "string",
        "null"
      ],
      "description": "Category"
    },
    "externalUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "URL of an external entity associated with the rule"
    },
    "status": {
      "$ref": "#/$defs/DataQualityStatusEnum"
    }
  },
  "$defs": {
    "DataQualityStatusEnum": {
      "type": "string",
      "description": "",
      "x-enumNames": [
        "Unknown",
        "Passed",
        "Warning",
        "Failed"
      ],
      "enum": [
        "Unknown",
        "Passed",
        "Warning",
        "Failed"
      ]
    },
    "RuleCheck": {
      "type": "object",
      "description": "Data quality rule check.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique rule check identifier. Example: 53768fce-c7c4-4216-bc5b-6d477abe2012",
          "format": "guid"
        },
        "ruleId": {
          "type": "string",
          "description": "Unique rule identifier. Example: ec64748c-059e-4a6a-a9db-5f9e634a2da8",
          "format": "guid"
        },
        "userId": {
          "type": "string",
          "description": "User unique identifier (creator)",
          "format": "guid"
        },
        "creationTime": {
          "type": "string",
          "description": "Creation date",
          "format": "date-time"
        },
        "status": {
          "description": "Check status. Must be one of: unknown, passed, warning, or failed",
          "oneOf": [
            {
              "$ref": "#/$defs/DataQualityStatusEnum"
            }
          ]
        },
        "message": {
          "type": [
            "string",
            "null"
          ],
          "description": "Short message about the check"
        },
        "detail": {
          "type": [
            "string",
            "null"
          ],
          "description": "Additional information about the check"
        }
      }
    },
    "RuleTypeEnum": {
      "type": "string",
      "description": "Data quality rule type using the 7 dimensions of data quality assessment.",
      "x-enumNames": [
        "Completeness",
        "Accuracy",
        "Consistency",
        "Validity",
        "Uniqueness",
        "Integrity",
        "Timeliness"
      ],
      "enum": [
        "Completeness",
        "Accuracy",
        "Consistency",
        "Validity",
        "Uniqueness",
        "Integrity",
        "Timeliness"
      ]
    },
    "SeverityEnum": {
      "type": "string",
      "description": "Data quality rule severity based on the four dimensions of sifflet data quality assessment.",
      "x-enumNames": [
        "Low",
        "Moderate",
        "High",
        "Critical"
      ],
      "enum": [
        "Low",
        "Moderate",
        "High",
        "Critical"
      ]
    }
  }
}