{
  "$id": "https://vendia.net/schemas/demos/loans.schema.json",
  "$schema": "https://json-schema.org/draft-07/schema#",
  "description": "Single Source of Loan Truth",
  "properties": {
    "Loan": {
      "description": "Whole loans that need to be serviced, and may securitized",
      "items": {
        "properties": {
          "additionalResources": {
            "description": "Resources that may help the borrower address payment challenges",
            "items": {
              "properties": {
                "description": {
                  "description": "Name of the program or resource",
                  "type": "string"
                },
                "uri": {
                  "description": "Link to the program or resource",
                  "format": "uri",
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "borrowerCreditScore": {
            "description": "Credit score of borrower",
            "maximum": 850,
            "minimum": 0,
            "type": "integer"
          },
          "delinquencyStatus": {
            "description": "Current delinquency status of the loan, based on the current reporting period",
            "enum": [
              "CURRENT",
              "LATE",
              "DELINQUENT"
            ],
            "type": "string"
          },
          "interestRatePercent": {
            "description": "Current loan interest rate, as a percent",
            "maximum": 100,
            "minimum": 0,
            "type": "number"
          },
          "loanIdentifier": {
            "description": "Globally unique loan identifier, set by the original lender",
            "pattern": "[0-9]{16}",
            "type": "string"
          },
          "loanToValuePercent": {
            "description": "Current loan to value ratio, as a percentage",
            "maximum": 100,
            "minimum": 0,
            "type": "number"
          },
          "numberOfUnits": {
            "description": "Number of units in the property",
            "minimum": 0,
            "type": "integer"
          },
          "originationDate": {
            "description": "Date loan originated",
            "format": "date",
            "type": "string"
          },
          "portfolioIdentifier": {
            "description": "Unique identifier of the portfolio in which this Loan resides",
            "pattern": "[A-Z0-9]{8}",
            "type": "string"
          },
          "unpaidPrincipalBalance": {
            "description": "Current unpaid principal balance amount",
            "type": "number"
          },
          "validationStatus": {
            "description": "The validation status of the loan",
            "enum": [
              "PENDING",
              "VALID",
              "INVALID",
              "ERROR"
            ],
            "type": "string"
          }
        },
        "required": [
          "loanIdentifier",
          "originationDate",
          "borrowerCreditScore",
          "numberOfUnits",
          "delinquencyStatus",
          "interestRatePercent",
          "loanToValuePercent",
          "unpaidPrincipalBalance"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "LoanPortfolio": {
      "description": "A collection of Loans along with metadata about the loans, modeled as a portfolio",
      "items": {
        "properties": {
          "delinquencyPercentage": {
            "description": "The percent of currently late or delinquent Loans in the Loan Portfolio",
            "type": "number"
          },
          "portfolioIdentifier": {
            "description": "Unique identifier of this Loan Portfolio",
            "pattern": "[A-Z0-9]{8}",
            "type": "string"
          },
          "portfolioName": {
            "description": "Descriptive name of this Loan Portfolio",
            "type": "string"
          },
          "weightedAverageInterestRate": {
            "description": "The percent of currently delinquent Loans in the Loan Portfolio",
            "type": "number"
          }
        },
        "required": [
          "portfolioIdentifier",
          "portfolioName"
        ],
        "type": "object"
      },
      "type": "array"
    }
  },
  "title": "Loan Marketplace",
  "type": "object",
  "x-vendia-acls": {
    "LoanAcl": {
      "type": "Loan"
    },
    "LoanPortfolioAcl": {
      "type": "LoanPortfolio"
    }
  }
}