{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:pacs.003.001.09",
  "title": "FIToFICustomerDirectDebit — pacs.003.001.09 (SBV profile)",
  "description": "ISO 20022 pacs.003.001.09: Ghi nợ liên ngân hàng cho khách hàng",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["FIToFICstmrDrctDbt"],
      "properties": {
        "FIToFICstmrDrctDbt": {
          "type": "object",
          "required": ["GrpHdr", "DrctDbtTxInf"],
          "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" } } } } }
              }
            },
            "DrctDbtTxInf": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "required": ["PmtId", "InstdAmt", "Cdtr", "CdtrAcct", "CdtrAgt", "Dbtr", "DbtrAcct", "DbtrAgt"],
                "properties": {
                  "PmtId":    { "type": "object", "required": ["EndToEndId", "UETR"], "properties": { "EndToEndId": { "type": "string", "maxLength": 35 }, "UETR": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" } } },
                  "InstdAmt": { "type": "object", "required": ["_", "$"], "properties": { "_": { "type": "string" }, "$": { "type": "object", "properties": { "Ccy": { "type": "string", "pattern": "^[A-Z]{3}$" } } } } },
                  "Cdtr":     { "type": "object", "required": ["Nm"], "properties": { "Nm": { "type": "string", "maxLength": 140 } } },
                  "CdtrAcct": { "type": "object", "required": ["Id"] },
                  "CdtrAgt":  { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } },
                  "Dbtr":     { "type": "object", "required": ["Nm"], "properties": { "Nm": { "type": "string", "maxLength": 140 } } },
                  "DbtrAcct": { "type": "object", "required": ["Id"] },
                  "DbtrAgt":  { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } }
                }
              }
            }
          }
        }
      }
    }
  }
}
