{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "KBX Field Dictionary",
  "type": "object",
  "required": ["version", "fields"],
  "properties": {
    "version": {"type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$"},
    "description": {"type": "string"},
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["key", "label", "dataType", "importable", "exportable", "sensitive"],
        "properties": {
          "key": {"type": "string", "pattern": "^[a-z][A-Za-z0-9]*$"},
          "label": {"type": "string", "minLength": 1},
          "aliases": {"type": "array", "items": {"type": "string", "minLength": 1}},
          "dataType": {"enum": ["text","code","integer","decimal","quantity","money","date","datetime","boolean","lookup","status"]},
          "required": {"type": "boolean"},
          "maxLength": {"type": "integer", "minimum": 1},
          "precision": {"type": "integer", "minimum": 1},
          "scale": {"type": "integer", "minimum": 0},
          "lookupEntity": {"type": "string"},
          "readonly": {"type": "boolean"},
          "importable": {"type": "boolean"},
          "exportable": {"type": "boolean"},
          "sensitive": {"type": "boolean"},
          "masking": {"enum": ["name","phone","address","partial"]},
          "helpText": {"type": "string"},
          "deprecated": {"type": "boolean"},
          "replacementKey": {"type": "string"}
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
