{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/moneyhub/main/json-schema/moneyhub-spending-goal-schema.json",
  "title": "SpendingGoal",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/moneyhub-spending-goals-api-openapi.yml#/components/schemas/SpendingGoal",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "categoryId": {
      "type": "string",
      "pattern": "^(std|cus):(\\w|-)+$"
    },
    "dateCreated": {
      "format": "date-time",
      "type": "string"
    },
    "periodType": {
      "type": "string",
      "enum": [
        "monthly",
        "annual"
      ]
    },
    "periodStart": {
      "type": "string",
      "pattern": "^(0?[1-9]|[12][0-9]|3[01])(-(0?[1-9]|1[012]))?$"
    },
    "id": {
      "description": "The unique id of the spending goal",
      "type": "string"
    },
    "amount": {
      "properties": {
        "value": {
          "description": "The value of the amount in minor units of the currency, eg. pennies for GBP.",
          "type": "integer",
          "minimum": 0
        },
        "majorUnits": {
          "description": "The major units of the value, based on the values currency, eg. pounds for GBP.",
          "type": "integer"
        },
        "minorUnits": {
          "description": "The minor units of the value, based on the values currency, eg. pennies for GBP.",
          "type": "integer"
        },
        "currency": {
          "description": "The currency of the amount.",
          "type": "string"
        }
      },
      "required": [
        "value",
        "currency"
      ],
      "type": "object"
    },
    "spending": {
      "items": {
        "additionalProperties": false,
        "properties": {
          "date": {
            "type": "string"
          },
          "spent": {
            "description": "The spending analysis amount of the specified month expressed in minor units of the currency.",
            "type": "integer"
          }
        },
        "required": [
          "date",
          "spent"
        ],
        "type": "object"
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "dateCreated",
    "categoryId",
    "amount",
    "periodStart",
    "periodType",
    "spending"
  ]
}