{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:pacs.010.001.05",
  "title": "FinancialInstitutionDirectDebit — pacs.010.001.05 (SBV profile)",
  "description": "ISO 20022 pacs.010.001.05: Ghi nợ liên ngân hàng NHNN ↔ NHTM",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["FIDrctDbt"],
      "properties": {
        "FIDrctDbt": {
          "type": "object",
          "required": ["GrpHdr", "CdtInstr"],
          "properties": {
            "GrpHdr": {
              "type": "object",
              "required": ["MsgId", "CreDtTm", "NbOfTxs", "SttlmInf", "InstgAgt", "InstdAgt"],
              "properties": {
                "MsgId":    { "type": "string", "maxLength": 35 },
                "CreDtTm":  { "type": "string", "format": "date-time" },
                "NbOfTxs":  { "type": "string", "pattern": "^[0-9]{1,15}$" },
                "SttlmInf": { "type": "object", "required": ["SttlmMtd"], "properties": { "SttlmMtd": { "type": "string", "enum": ["INDA","INGA","COVE","CLRG"] } } },
                "InstgAgt": { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } },
                "InstdAgt": { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } }
              }
            },
            "CdtInstr": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "required": ["CdtId", "IntrBkSttlmAmt", "IntrBkSttlmDt", "CdtrAgt", "Cdtr", "CdtrAcct", "DbtrAgt"],
                "properties": {
                  "CdtId":              { "type": "string", "maxLength": 35 },
                  "IntrBkSttlmAmt":     { "type": "object", "required": ["_", "$"], "properties": { "_": { "type": "string" }, "$": { "type": "object", "properties": { "Ccy": { "type": "string" } } } } },
                  "IntrBkSttlmDt":      { "type": "string", "format": "date" },
                  "Purp":               { "type": "object", "properties": { "Cd": { "type": "string", "maxLength": 4 } } },
                  "CdtrAgt":            { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } },
                  "Cdtr":               { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } },
                  "CdtrAcct":           { "type": "object", "required": ["Id"] },
                  "DbtrAgt":            { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } }
                }
              }
            }
          }
        }
      }
    }
  }
}
