{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "sailpoint.isc.transforms.replaceAll.schema.json",
  "title": "SailPoint ISC Transform Schema - replaceAll",
  "description": "Strict schema for the SailPoint ISC replaceAll transform. Performs multiple find-and-replace operations in a single pass against the input string. Each key in the table is a Java regular expression pattern; its value is the replacement string. All patterns are applied simultaneously against the original input — not sequentially. Pattern matching is case-sensitive by default. Use an empty string value to delete all text matching a pattern. Unlike the single replace transform, replaceAll can handle multiple distinct patterns in one operation.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "type",
    "name",
    "attributes"
  ],
  "properties": {
    "type": {
      "const": "replaceAll",
      "description": "Transform operation type. Must be exactly 'replaceAll'."
    },
    "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",
      "additionalProperties": false,
      "required": [
        "table"
      ],
      "description": "Required container for replaceAll operation attributes.",
      "properties": {
        "table": {
          "type": "object",
          "description": "Required map of Java regex patterns (keys) to replacement strings (values). Each key is compiled as a Java regular expression and matched against the input string — all occurrences of each matching pattern are replaced with the corresponding value. Rules: (1) All values must be static strings; use an empty string \"\" to delete all matched text. (2) Pattern matching is case-sensitive — use character classes (e.g., '[Aa]') or separate entries for case variants. (3) All patterns apply simultaneously against the original input string in a single pass. (4) For literal special regex characters, use bracket notation (e.g., '[.]' for a literal dot, '[+]' for a literal plus).",
          "minProperties": 1,
          "additionalProperties": {
            "type": "string",
            "description": "Replacement string. All occurrences of the matching regex pattern are replaced with this value. Use an empty string to delete matched text."
          }
        },
        "input": {
          "description": "Optional explicit input that provides the string to apply pattern replacements to. If omitted, the transform uses the source and attribute combination configured in the identity profile UI. When provided, must be a nested transform object or a static string.",
          "anyOf": [
            {
              "type": "string",
              "description": "Static string value to apply replacements to."
            },
            {
              "$ref": "#/$defs/NestedTransform"
            }
          ]
        }
      }
    }
  },
  "$defs": {
    "NestedTransform": {
      "type": "object",
      "description": "A nested transform object that provides the string input for the replaceAll operation. Its output string is the value that pattern replacements are applied to. The 'name' field is optional in nested transforms per SailPoint docs.",
      "additionalProperties": false,
      "required": [
        "type",
        "attributes"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Optional 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 operation type of the nested transform (e.g., 'accountAttribute', 'identityAttribute', 'trim')."
        },
        "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": [
    {
      "name": "Remove Special Characters",
      "type": "replaceAll",
      "attributes": {
        "table": {
          "[^A-Za-z0-9]": ""
        }
      }
    },
    {
      "name": "Normalize Whitespace and Dots",
      "type": "replaceAll",
      "attributes": {
        "table": {
          "\\s+": "_",
          "[.]": "-"
        }
      }
    },
    {
      "name": "Remove Vowels",
      "type": "replaceAll",
      "attributes": {
        "table": {
          "[aeiouAEIOU]": ""
        }
      }
    },
    {
      "name": "Sanitize Username from Account Attribute",
      "type": "replaceAll",
      "attributes": {
        "table": {
          "\\s+": ".",
          "[^A-Za-z0-9.]": ""
        },
        "input": {
          "type": "accountAttribute",
          "attributes": {
            "sourceName": "HR Source",
            "attributeName": "displayName"
          }
        }
      }
    }
  ]
}
