{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.msadsnetwork.com/downloads/schemas/li-lang-intent.schema.json",
  "title": "lang_intent v0.1 (public draft) — content.ext.lang_intent",
  "type": "object",
  "required": [
    "ver",
    "code",
    "script",
    "variant",
    "source"
  ],
  "additionalProperties": false,
  "properties": {
    "ver": {
      "const": "0.1"
    },
    "code": {
      "type": "string",
      "pattern": "^[a-z]{2,3}$"
    },
    "script": {
      "type": "string",
      "pattern": "^[A-Z][a-z]{3}$"
    },
    "variant": {
      "enum": [
        "standard",
        "romanized",
        "code_mixed"
      ]
    },
    "mix": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z]{2,3}$"
      },
      "minItems": 1,
      "maxItems": 3,
      "uniqueItems": true
    },
    "mix_ratio": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "source": {
      "enum": [
        "publisher",
        "detector",
        "user_setting"
      ]
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "cat_lang": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "cattax",
          "cat"
        ],
        "properties": {
          "cattax": {
            "type": "integer"
          },
          "cat": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "variant": {
            "const": "romanized"
          }
        }
      },
      "then": {
        "properties": {
          "script": {
            "const": "Latn"
          },
          "code": {
            "not": {
              "enum": [
                "en",
                "fr",
                "de",
                "es",
                "it",
                "pt",
                "nl",
                "tr",
                "id",
                "ms",
                "sw"
              ]
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "variant": {
            "const": "code_mixed"
          }
        }
      },
      "then": {
        "required": [
          "mix"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "source": {
            "const": "detector"
          }
        }
      },
      "then": {
        "required": [
          "confidence"
        ]
      }
    }
  ]
}