{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:coos:schema:CommonProperty",
  "title": "CommonProperty",
  "description": "An identifiable area of common property, including limited common property designated for the exclusive use of one or more strata lots.",
  "type": "object",
  "x-domain": "core",
  "x-status": "experimental",
  "x-since": "0.1.0-draft",
  "x-relationships": [
    {
      "field": "strataCorporationId",
      "target": "StrataCorporation",
      "cardinality": "one",
      "required": true
    },
    {
      "field": "designatedStrataLotIds",
      "target": "StrataLot",
      "cardinality": "many",
      "required": false
    },
    {
      "field": "buildingId",
      "target": "Building",
      "cardinality": "one",
      "required": false
    }
  ],
  "x-validationRules": [
    "designatedStrataLotIds must contain at least one value when kind is limitedCommonProperty.",
    "designatedStrataLotIds must be empty or absent when kind is commonProperty."
  ],
  "x-legalReviewNotes": [
    "Confirm how designation method (on the plan, or by resolution) should be recorded."
  ],
  "required": [
    "id",
    "strataCorporationId",
    "description",
    "kind"
  ],
  "additionalProperties": false,
  "properties": {
    "id": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "Stable identifier of this CommonProperty record."
    },
    "strataCorporationId": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "The strata corporation this record belongs to.",
      "x-references": "StrataCorporation"
    },
    "description": {
      "type": "string",
      "description": "Description of the area (for example \"Parking stall 14\", \"Rooftop deck\").",
      "maxLength": 500
    },
    "kind": {
      "type": "string",
      "description": "Whether the area is general or limited common property.",
      "enum": [
        "commonProperty",
        "limitedCommonProperty"
      ],
      "x-enumDescriptions": {
        "commonProperty": "Common property available to all owners.",
        "limitedCommonProperty": "Common property designated for the exclusive use of the owners of one or more strata lots."
      }
    },
    "designatedStrataLotIds": {
      "type": "array",
      "description": "Strata lots with exclusive use, when kind is limitedCommonProperty.",
      "items": {
        "$ref": "urn:coos:schema:common#/$defs/Identifier",
        "x-references": "StrataLot"
      },
      "uniqueItems": true
    },
    "buildingId": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "Building the area is in or attached to, if applicable.",
      "x-references": "Building"
    },
    "extensions": {
      "$ref": "urn:coos:schema:common#/$defs/Extensions",
      "description": "Implementation-specific data, namespaced by reverse domain."
    }
  }
}
