{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://ordinis.nstart.cloud/schemas/cuod/consumer/1.0.0",
  "title": "Consumer (потребитель данных ДЗЗ)",
  "description": "Юридические лица — заказчики/получатели снимков и продуктов ЦУОД.",
  "type": "object",
  "required": ["code", "name", "consumer_type", "status"],
  "additionalProperties": false,
  "x-id-source": "code",
  "properties": {
    "code": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]{1,31}$", "x-unique": true },
    "name": {
      "type": "object", "x-localized": true,
      "patternProperties": { "^[a-z]{2}-[A-Z]{2}$": { "type": "string", "minLength": 1 } },
      "required": ["ru-RU"]
    },
    "full_name": {
      "type": "object", "x-localized": true,
      "patternProperties": { "^[a-z]{2}-[A-Z]{2}$": { "type": "string" } }
    },
    "consumer_type": {
      "type": "string",
      "description": "FK на consumer_type.code.",
      "pattern": "^[A-Z][A-Z0-9_]{1,31}$",
      "x-references": "consumer_type.code"
    },
    "industry_sector": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]{1,31}$" },
    "country": { "type": "string", "pattern": "^[A-Z]{2}$" },
    "inn": {
      "type": "string",
      "description": "ИНН (10 или 12 цифр).",
      "pattern": "^[0-9]{10}$|^[0-9]{12}$"
    },
    "status": { "type": "string", "enum": ["active", "archived"] }
  }
}
