{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "CustomFormatter JSON",
  "description": "CustomFormatter renderer for SharePoint lists",
  "definitions": {
    "customAction": {
      "type": "object",
      "additionalProperties": false,
      "title": "Action object",
      "description": "Action object for a custom action button",
      "properties": {
        "action": {
          "description": "Name of the action that the custom action button will execute",
          "enum": [
            "defaultClick",
            "executeFlow",
            "share",
            "delete",
            "editProps",
            "openContextMenu",
            "setValue"
          ]
        },
        "actionParams": {
          "description": "Parameters for the executeFlow action",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ],
          "default": ""
        },
        "actionInput": {
          "description": "Input for setValue action",
          "type": "object",
          "patternProperties": {
            "^[a-zA-Z_].+$": {
              "description": "Specifies value to set for each field",
              "anyOf": [
                {
                  "$ref": "#/definitions/expression"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          "default": {
            "FieldName": "Value to set"
          }
        }
      },
      "default": {
        "action": ""
      },
      "required": [
        "action"
      ]
    },
    "expression": {
      "type": "object",
      "additionalProperties": false,
      "title": "Expression object JSON",
      "description": "Expression object for CustomFormatter JSON",
      "properties": {
        "operator": {
          "description": "Operator for this expression",
          "enum": [
            "+",
            "-",
            "/",
            "*",
            "<",
            ">",
            "%",
            "==",
            "!=",
            "<=",
            ">=",
            "||",
            "&&",
            "?",
            ":",
            "abs",
            "addDays",
            "addMinutes",
            "appendTo",
            "cos",
            "ceiling",
            "Date()",
            "endsWith",
            "floor",
            "getDate",
            "getMonth",
            "getYear",
            "getUserImage",
            "indexOf",
            "join",
            "lastIndexOf",
            "length",
            "loopIndex",
            "Number()",
            "padStart",
            "padEnd",
            "pow",
            "removeFrom",
            "replace",
            "replaceAll",
            "toDateString()",
            "toLocaleDateString()",
            "toLocaleString()",
            "toLocaleTimeString()",
            "toLowerCase",
            "toString()",
            "toUpperCase",
            "sin",
            "split",
            "startsWith",
            "substring"
          ]
        },
        "operands": {
          "description": "Operands for this expression",
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "boolean"
              },
              {
                "type": "number"
              },
              {
                "type": "object",
                "$ref": "#/definitions/expression"
              }
            ]
          }
        }
      },
      "required": [
        "operator",
        "operands"
      ]
    }
  },
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "description": "schema of the JSON",
      "type": "string"
    },
    "debugMode": {
      "description": "Is this JSON in debug mode?",
      "type": "boolean",
      "default": true
    },
    "elmType": {
      "description": "The type of element to create",
      "enum": [
        "div",
        "button",
        "span",
        "a",
        "img",
        "svg",
        "path",
        "filepreview",
        "p"
      ]
    },
    "children": {
      "description": "Children elements",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "#"
      },
      "default": [
        {
          "elmType": ""
        }
      ]
    },
    "txtContent": {
      "anyOf": [
        {
          "$ref": "#/definitions/expression"
        },
        {
          "type": "string"
        }
      ]
    },
    "style": {
      "type": "object",
      "description": "Specifies the style object for this element",
      "patternProperties": {
        "^(?:[a-z]+(?:-[a-z]+)?|--inline-editor-border(?:-[a-z]+))$": {
          "description": "Specifies style attributes for this element",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        }
      },
      "default": {}
    },
    "customRowAction": {
      "anyOf": [
        {
          "$ref": "#/definitions/customAction"
        }
      ]
    },
    "attributes": {
      "type": "object",
      "description": "Additional attributes to be added to elmType",
      "properties": {
        "href": {
          "description": "Specifies the href attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "rel": {
          "description": "Specifies the rel attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "src": {
          "description": "Specifies the src attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "class": {
          "description": "Specifies the class attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "target": {
          "description": "Specifies the target attribute, used primarily for <a> element types.",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "role": {
          "description": "Specifies the role attribute, used accessibility.",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "iconName": {
          "description": "Specifies the Fabric icon to display before this element",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "d": {
          "description": "Specifies the d attribute. Used primarily for svg path elements",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "title": {
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "alt": {
          "description": "Specifies the alt attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        },
        "data-interception": {
          "description": "Specifies the data-interception attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "enum": [
                "on",
                "off"
              ]
            }
          ]
        },
        "viewBox": {
          "description": "Specifies the svg viewBox attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string",
              "pattern": "^(?:[\\-+]?\\d+\\s*[\\s,]\\s*){3}(?:[\\-+]?\\d+)$"
            }
          ]
        },
        "preserveAspectRatio": {
          "description": "Specifies the preserveAspectRatio attribute",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string",
              "pattern": "^(?:x(?:Min|Mid|Max)Y(?:Min|Mid|Max)(?:\\s+(?:slice|meet))|none)$"
            }
          ]
        },
        "draggable": {
          "description": "Specifies specifies whether an element is draggable or not",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "enum": [
                "true",
                "false"
              ]
            }
          ]
        }
      },
      "patternProperties": {
        "^aria\\-[a-z]+$": {
          "description": "Specifies aria- attributes for the element",
          "anyOf": [
            {
              "$ref": "#/definitions/expression"
            },
            {
              "type": "string"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "forEach": {
      "type": "string",
      "description": "For loop properties. The element will be rendered repeatedly based on an array.",
      "pattern": "^[^\\]\\$@\\. ]+ in (\\@currentField|\\[\\$.+\\])$",
      "default": "iteratorName in [$FieldName]"
    },
    "defaultHoverField": {
      "type": "string",
      "description": "Column name to show the default hover card of",
      "pattern": "(\\@currentField(.\\w+)*|\\[\\$.+\\])$",
      "default": "[$FieldName]"
    },
    "customCardProps": {
      "type": "object",
      "description": "Object that defines custom card props on hover/click",
      "properties": {
        "openOnEvent": {
          "description": "Event name to decide on which the customCard should open",
          "enum": [
            "click",
            "hover"
          ]
        },
        "directionalHint": {
          "description": "Specify the direction relative to the target in which CustomCard will be positioned",
          "enum": [
            "topCenter",
            "bottomCenter",
            "leftCenter",
            "rightCenter"
          ]
        },
        "isBeakVisible": {
          "description": "Specify if the beak is to be shown or not",
          "type": "boolean",
          "default": true
        },
        "beakStyle": {
          "type": "object",
          "description": "Specifies the style object for custom card's beak",
          "patternProperties": {
            "^[a-z]+(?:-[a-z]+)?$": {
              "description": "Specifies style attributes for for custom card's beak",
              "type": "string"
            }
          }
        },
        "formatter": {
          "description": "JSON object that defines formatting for customCards",
          "$ref": "#"
        }
      },
      "required": [
        "formatter",
        "openOnEvent"
      ],
      "default": {
        "openOnEvent": "click",
        "formatter": {
          "elmType": ""
        }
      }
    },
    "columnFormatterReference": {
      "type": "string",
      "description": "Referring the column formatter of specified field",
      "pattern": "\\[\\$.+\\]$",
      "default": "[$FieldName]"
    },
    "inlineEditField": {
      "type": "string",
      "description": "Allow inline editing for a field",
      "pattern": "(\\@currentField(.\\w+)*|\\[\\$.+\\])$",
      "default": "[$FieldName]"
    },
    "filePreviewProps": {
      "type": "object",
      "description": "Object that defines additional properties to style fileTypeIcon and brandTypeIcon in the filepreview element",
      "properties": {
        "fileTypeIconClass": {
          "description": "Class name or an Expression which evaluates to one, to add to the FileTypeIcon",
          "$ref": "#/properties/attributes/properties/class"
        },
        "fileTypeIconStyle": {
          "description": "Style object or an Expression which evaluates to one, to add to the FileTypeIcon",
          "$ref": "#/properties/style"
        },
        "brandTypeIconClass": {
          "description": "Class name or an Expression which evaluates to one, to add to the BrandTypeIcon",
          "$ref": "#/properties/attributes/properties/class"
        },
        "brandTypeIconStyle": {
          "description": "Style object or an Expression which evaluates to one, to add to the BrandTypeIcon",
          "$ref": "#/properties/style"
        }
      }
    }
  },
  "oneOf": [
    {
      "required": [
        "elmType"
      ]
    },
    {
      "required": [
        "columnFormatterReference"
      ]
    }
  ]
}