{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "sailpoint.isc.transforms.conditional.schema.json",
  "title": "SailPoint ISC Transform Schema - conditional",
  "description": "Strict schema for the SailPoint ISC Conditional transform. Evaluates a 'ValueA eq ValueB' expression and returns positiveCondition (true) or negativeCondition (false). Only 'eq' is supported — other operators throw IllegalArgumentException at runtime. Comparisons are case-sensitive. Operands cannot be null at runtime.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "type",
    "name",
    "attributes"
  ],
  "properties": {
    "type": {
      "const": "conditional",
      "description": "Transform operation type. Must be exactly 'conditional'."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Display name for this transform, shown in UI dropdowns and identity profile mappings."
    },
    "requiresPeriodicRefresh": {
      "type": "boolean",
      "default": false,
      "description": "If true, re-evaluates this transform during the nightly identity refresh cycle. Default is false."
    },
    "attributes": {
      "type": "object",
      "description": "Conditional logic configuration. Required: expression, positiveCondition, negativeCondition. Optional: dynamic variable keys (any additional key) whose values are static strings or nested transforms, referenced via $variableName in the expression and conditions.",
      "required": [
        "expression",
        "positiveCondition",
        "negativeCondition"
      ],
      "properties": {
        "expression": {
          "type": "string",
          "minLength": 1,
          "pattern": "^.+\\s+eq\\s+.+$",
          "description": "Equality expression of the form '<ValueA> eq <ValueB>'. RULES: (1) Only 'eq' operator is supported — !=, ==, >, <, ne, gt, lt etc. throw IllegalArgumentException. (2) Comparisons are case-sensitive: 'Engineering' != 'engineering'. (3) Operands cannot be null at runtime. (4) Variables are referenced with $variableName syntax and must be declared as keys in attributes."
        },
        "positiveCondition": {
          "type": "string",
          "description": "Value returned when expression evaluates to true. Can be a static string (e.g., 'Active') or a $variableName reference to a declared variable in attributes. Can be empty string to return a blank value."
        },
        "negativeCondition": {
          "type": "string",
          "description": "Value returned when expression evaluates to false. Can be a static string (e.g., 'Inactive') or a $variableName reference to a declared variable in attributes. Can be empty string to return a blank value."
        }
      },
      "additionalProperties": {
        "description": "Dynamic variable declaration. Key becomes the variable name, referenced as $keyName in expression, positiveCondition, or negativeCondition. Value must be a static string or a nested transform object.",
        "anyOf": [
          {
            "type": "string",
            "description": "Static string value for this variable."
          },
          {
            "$ref": "#/$defs/NestedTransform"
          }
        ]
      }
    }
  },
  "$defs": {
    "NestedTransform": {
      "type": "object",
      "description": "Nested transform object used as a dynamic variable. The 'name' field is optional in nested transforms per SailPoint docs examples.",
      "additionalProperties": false,
      "required": [
        "type",
        "attributes"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Optional transform ID when referencing an existing saved transform."
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "Optional display name for the nested transform."
        },
        "type": {
          "type": "string",
          "minLength": 1,
          "description": "The transform operation type (e.g., 'accountAttribute', 'static', 'dateFormat')."
        },
        "requiresPeriodicRefresh": {
          "type": "boolean",
          "description": "Whether this nested transform re-evaluates during nightly refresh."
        },
        "attributes": {
          "type": "object",
          "additionalProperties": true,
          "description": "Operation-specific attributes for the nested transform."
        }
      }
    }
  },
  "examples": [
    {
      "type": "conditional",
      "name": "Department Science Check",
      "attributes": {
        "expression": "$department eq Science",
        "positiveCondition": "true",
        "negativeCondition": "false",
        "department": {
          "type": "accountAttribute",
          "attributes": {
            "sourceName": "HR Source",
            "attributeName": "department"
          }
        }
      }
    },
    {
      "type": "conditional",
      "name": "Assign Building by Department",
      "attributes": {
        "expression": "$department eq Science",
        "positiveCondition": "$scienceBuilding",
        "negativeCondition": "$adminBuilding",
        "department": {
          "type": "accountAttribute",
          "attributes": {
            "sourceName": "HR Source",
            "attributeName": "department"
          }
        },
        "scienceBuilding": {
          "type": "static",
          "attributes": {
            "value": "Building S"
          }
        },
        "adminBuilding": {
          "type": "static",
          "attributes": {
            "value": "Building A"
          }
        }
      }
    },
    {
      "type": "conditional",
      "name": "Active Employee Flag",
      "requiresPeriodicRefresh": true,
      "attributes": {
        "expression": "$workerStatus eq active",
        "positiveCondition": "true",
        "negativeCondition": "false",
        "workerStatus": {
          "type": "accountAttribute",
          "attributes": {
            "applicationName": "corp-hr-system",
            "attributeName": "WORKER_STATUS__c",
            "accountSortAttribute": "created",
            "accountSortDescending": true
          }
        }
      }
    }
  ]
}
