{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/carafe/_shared/latest--config.schema.json",
  "x-lintel": {
    "source": "https://carafe.fm/schema/draft-02/config.schema.json",
    "sourceSha256": "44acf5eaad32021565e5ea4af81c467744289087252c261e761efeec28f74f8e"
  },
  "type": "object",
  "additionalProperties": {
    "type": "object",
    "errorMessage": {
      "required": "must have properties source and type"
    },
    "allOf": [
      {
        "properties": {
          "source": {
            "enum": [
              "config",
              "data",
              "libraries"
            ]
          },
          "type": {
            "enum": [
              "boolean",
              "jsonArray",
              "jsonObject",
              "number",
              "text",
              "largeText",
              "cssSnippet",
              "htmlSnippet",
              "jsSnippet",
              "color",
              "padding",
              "textAlign",
              "verticalAlign",
              "fmpFileName",
              "fmpScriptName",
              "dropdown",
              "popup"
            ]
          },
          "value": {
            "type": [
              "number",
              "integer",
              "array",
              "object",
              "boolean",
              "string"
            ],
            "errorMessage": "non-null value is required when 'source' is config"
          },
          "path": {
            "type": "string",
            "pattern": "^(/[^/ ]*)+/?$",
            "errorMessage": "relative file path with a leading slash; required when 'source' is libraries"
          },
          "help": {
            "type": "string",
            "errorMessage": "optional explainer for the implementor"
          },
          "category": {
            "type": "string",
            "errorMessage": "optional"
          },
          "label": {
            "type": "string",
            "errorMessage": "optional"
          },
          "sort": {
            "type": "number",
            "errorMessage": "optional"
          },
          "possibleValues": {
            "type": "array",
            "errorMessage": "required when 'type' is dropdown or popup"
          }
        },
        "required": [
          "source",
          "type"
        ],
        "type": "object"
      },
      {
        "errorMessage": "'source' is config so must have a 'value'",
        "if": {
          "properties": {
            "source": {
              "const": "config"
            }
          }
        },
        "then": {
          "required": [
            "value"
          ]
        }
      },
      {
        "errorMessage": "'source' is libraries so must have a 'path'",
        "if": {
          "properties": {
            "source": {
              "const": "libraries"
            }
          }
        },
        "then": {
          "required": [
            "path"
          ]
        }
      },
      {
        "errorMessage": "'type' is dropdown or popup so must have a 'possibleValues'",
        "if": {
          "properties": {
            "type": {
              "enum": [
                "dropdown",
                "popup"
              ]
            }
          }
        },
        "then": {
          "required": [
            "possibleValues"
          ]
        }
      }
    ]
  }
}
