{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:open-utility-stack:common:money:1",
  "title": "common/money@1",
  "description": "An exact amount of money. The value is a decimal string, never a JSON number; `scale` is its number of fractional digits and must match it. Negative is a credit to the customer.",
  "$defs": {
    "Money": {
      "type": "object",
      "additionalProperties": false,
      "required": ["currency", "value", "scale"],
      "properties": {
        "currency": {
          "description": "ISO 4217 alphabetic code.",
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "value": {
          "description": "Signed decimal string, no exponent, no leading zeros, no plus sign.",
          "type": "string",
          "pattern": "^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$"
        },
        "scale": {
          "description": "The number of fractional digits in `value`.",
          "type": "integer",
          "minimum": 0,
          "maximum": 28
        }
      }
    },
    "Rate": {
      "description": "A fraction as a decimal string, such as a VAT rate of 0.19.",
      "type": "string",
      "pattern": "^(0(\\.[0-9]+)?|1(\\.0+)?)$"
    }
  }
}
