{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://elainabaka.com/hoc/data/cap/goc.schema.json",
  "title": "Bản gốc (Tổng hợp) của mục Học meinya-hoc",
  "description": "data/goc.json: các mạch tư duy chạy xuyên bốn cấp; mỗi nút có bốn tầng lời (tiểu học, cấp 2, cấp 3, đại học) và vùng sức của tuổi. tools/chung_cat.py chưng cất ra từng cấp.",
  "type": "object",
  "additionalProperties": false,
  "required": ["ten", "cap_nhat", "giay_phep", "cap", "nguyen_tac", "mach", "nodes"],
  "properties": {
    "ten": {"type": "string", "minLength": 2, "maxLength": 80},
    "mo_ta": {"type": "string", "maxLength": 400},
    "cap_nhat": {"$ref": "#/$defs/ngay"},
    "giay_phep": {"const": "CC BY-SA 4.0"},
    "cap": {"type": "array", "minItems": 4, "maxItems": 4, "items": {"$ref": "#/$defs/cap"}},
    "nguyen_tac": {"type": "array", "minItems": 1, "maxItems": 8, "items": {"$ref": "#/$defs/nguyen_tac"}},
    "mach": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/mach"}},
    "nodes": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/node"}}
  },
  "$defs": {
    "id": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "maxLength": 60},
    "cap_key": {"enum": ["tieu-hoc", "cap-2", "cap-3", "dai-hoc"]},
    "ngay": {"type": "string", "pattern": "^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$"},
    "chu": {"type": "string", "minLength": 3, "maxLength": 600},
    "nguon_list": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/nguon"}},
    "cap": {
      "type": "object", "additionalProperties": false, "required": ["key", "ten", "tuoi", "dau_oc", "nguon"],
      "properties": {
        "key": {"$ref": "#/$defs/cap_key"},
        "ten": {"type": "string", "minLength": 2, "maxLength": 40},
        "tuoi": {"type": "string", "minLength": 2, "maxLength": 40},
        "dau_oc": {"$ref": "#/$defs/chu"},
        "nguon": {"$ref": "#/$defs/nguon_list"}
      }
    },
    "nguyen_tac": {
      "type": "object", "additionalProperties": false, "required": ["ten", "loi", "nguon"],
      "properties": {
        "ten": {"type": "string", "minLength": 2, "maxLength": 60},
        "loi": {"$ref": "#/$defs/chu"},
        "nguon": {"$ref": "#/$defs/nguon_list"}
      }
    },
    "mach": {
      "type": "object", "additionalProperties": false, "required": ["id", "ten", "mo_ta"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "ten": {"type": "string", "minLength": 2, "maxLength": 60},
        "mo_ta": {"$ref": "#/$defs/chu"}
      }
    },
    "tang": {
      "type": "object", "additionalProperties": false, "required": ["vung", "loi"],
      "properties": {
        "vung": {"enum": ["vua", "thu-thach", "chua-nen"]},
        "loi": {"$ref": "#/$defs/chu"},
        "lam_thu": {"$ref": "#/$defs/chu"}
      }
    },
    "node": {
      "type": "object", "additionalProperties": false, "required": ["id", "mach", "ten", "cot_loi", "vi_sao", "tang", "nguon"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "mach": {"$ref": "#/$defs/id"},
        "ten": {"type": "string", "minLength": 2, "maxLength": 80},
        "cot_loi": {"$ref": "#/$defs/chu"},
        "vi_sao": {"$ref": "#/$defs/chu"},
        "lien_ket": {"type": "array", "maxItems": 6, "items": {"type": "string", "pattern": "^(toan|ly|hoa|van):[a-z0-9]+(-[a-z0-9]+)*$"}},
        "tang": {
          "type": "object", "additionalProperties": false, "required": ["tieu-hoc", "cap-2", "cap-3", "dai-hoc"],
          "properties": {
            "tieu-hoc": {"$ref": "#/$defs/tang"},
            "cap-2": {"$ref": "#/$defs/tang"},
            "cap-3": {"$ref": "#/$defs/tang"},
            "dai-hoc": {"$ref": "#/$defs/tang"}
          }
        },
        "nguon": {"$ref": "#/$defs/nguon_list"}
      }
    },
    "nguon": {
      "type": "object", "additionalProperties": false, "required": ["ten", "url", "doc"],
      "properties": {
        "ten": {"type": "string", "minLength": 3, "maxLength": 200},
        "url": {"type": "string", "pattern": "^https://[!#-;=?-~]+$", "maxLength": 300},
        "doc": {"$ref": "#/$defs/ngay"},
        "ghi_chu": {"type": "string", "maxLength": 300}
      }
    }
  }
}
