{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:coos:schema:Bylaw",
  "title": "Bylaw",
  "description": "A bylaw or rule of the strata corporation. Bylaws are adopted by the owners; rules may be made by council and later ratified.",
  "type": "object",
  "x-domain": "governance",
  "x-status": "proposed",
  "x-since": "0.1.0-draft",
  "x-relationships": [
    {
      "field": "strataCorporationId",
      "target": "StrataCorporation",
      "cardinality": "one",
      "required": true
    },
    {
      "field": "approvedByResolutionId",
      "target": "Resolution",
      "cardinality": "one",
      "required": false
    }
  ],
  "x-validationRules": [
    "filedDate applies only when kind is bylaw."
  ],
  "x-legalReviewNotes": [
    "Confirm when bylaws and rules take effect and how ratification of rules should be represented."
  ],
  "required": [
    "id",
    "strataCorporationId",
    "kind",
    "title",
    "status"
  ],
  "additionalProperties": false,
  "properties": {
    "id": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "Stable identifier of this Bylaw record."
    },
    "strataCorporationId": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "The strata corporation this record belongs to.",
      "x-references": "StrataCorporation"
    },
    "kind": {
      "type": "string",
      "description": "Whether this is a bylaw or a rule.",
      "enum": [
        "bylaw",
        "rule"
      ],
      "x-enumDescriptions": {
        "bylaw": "Bylaw.",
        "rule": "Rule."
      }
    },
    "reference": {
      "type": "string",
      "description": "Number or section reference used by the corporation (for example \"3.4\").",
      "maxLength": 32
    },
    "title": {
      "type": "string",
      "description": "Title or subject.",
      "minLength": 1,
      "maxLength": 200
    },
    "text": {
      "type": "string",
      "description": "Full text.",
      "maxLength": 50000
    },
    "status": {
      "type": "string",
      "description": "Current status.",
      "enum": [
        "proposed",
        "inEffect",
        "repealed"
      ],
      "x-enumDescriptions": {
        "proposed": "Proposed but not yet approved.",
        "inEffect": "Currently in effect.",
        "repealed": "Repealed or replaced."
      }
    },
    "approvedByResolutionId": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "Resolution that approved or ratified it.",
      "x-references": "Resolution"
    },
    "effectiveDate": {
      "$ref": "urn:coos:schema:common#/$defs/Date",
      "description": "Date it took effect."
    },
    "filedDate": {
      "$ref": "urn:coos:schema:common#/$defs/Date",
      "description": "Date a bylaw amendment was filed in the Land Title Office, where applicable."
    },
    "extensions": {
      "$ref": "urn:coos:schema:common#/$defs/Extensions",
      "description": "Implementation-specific data, namespaced by reverse domain."
    }
  }
}
