{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openmobiledocumentagent.org/schemas/v0.1/profile.schema.json",
  "title": "OMDA domain profile (§7)",
  "type": "object",
  "required": ["id", "version", "domain", "doc_types"],
  "additionalProperties": false,
  "properties": {
    "id": { "type": "string", "pattern": "^[a-z0-9.-]+$" },
    "version": { "type": "integer", "minimum": 1 },
    "domain": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
    "description": { "type": "string" },
    "doc_types": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "object",
        "required": ["fields", "entity_key"],
        "additionalProperties": false,
        "properties": {
          "description": { "type": "string" },
          "jurisdiction_bound": { "type": "boolean", "default": false },
          "fields": {
            "type": "object",
            "minProperties": 1,
            "additionalProperties": {
              "type": "object",
              "required": ["type", "sensitivity"],
              "additionalProperties": false,
              "properties": {
                "type": { "enum": ["string", "date", "country", "sex", "name", "amount", "code", "image"] },
                "sensitivity": { "$ref": "common.schema.json#/$defs/sensitivity" },
                "checks": { "type": "array", "items": { "type": "string" } },
                "derived_from": { "type": "string", "description": "Field this one is derived from (e.g. structured name parts)." },
                "export_default": { "type": "boolean", "default": true },
                "jurisdiction_checks": {
                  "type": "object",
                  "propertyNames": { "pattern": "^[a-z]{2}$" },
                  "additionalProperties": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          },
          "entity_key": { "type": "array", "minItems": 1, "items": { "type": "string" } },
          "validity": {
            "type": "object",
            "required": ["from", "until"],
            "properties": { "from": { "type": "string" }, "until": { "type": "string" } }
          },
          "groups": { "type": "array", "items": { "type": "string" } }
        }
      }
    },
    "mappings": { "type": "object", "additionalProperties": { "type": "string" } }
  }
}
