{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://onlyfarms.tenshisystems.com/data/schema.json",
  "title": "Only Farms public record",
  "description": "One published record. Category-specific fields live in attributes; data/categories.json defines them. Public records never carry email addresses, phone numbers or exact private coordinates.",
  "type": "object",
  "required": ["id", "slug", "category", "type", "title", "summary", "attributes", "county", "state", "location_public", "location_precision", "license", "published_at"],
  "properties": {
    "id": { "type": "string", "pattern": "^of-[a-z]+-[0-9]{4,}$" },
    "slug": { "type": "string", "pattern": "^[a-z0-9-]+$" },
    "status": { "enum": ["published", "withdrawn", "archived"] },
    "category": { "enum": ["land", "equipment", "livestock", "services"] },
    "type": { "type": "string", "description": "One of the category's types in data/categories.json" },
    "title": { "type": "string", "maxLength": 120 },
    "summary": { "type": "string", "maxLength": 400 },
    "description": { "type": "string" },
    "attributes": { "type": "object", "description": "Keys from the category's attributes in data/categories.json" },
    "price_text": { "type": "string", "description": "As the contributor wrote it. Only Farms is not a party to any sale." },
    "county": { "type": "string" },
    "state": { "type": "string", "pattern": "^[A-Z]{2}$" },
    "fips": { "type": "string", "pattern": "^[0-9]{5}$" },
    "location_public": {
      "type": "object", "required": ["lat", "lng"],
      "properties": { "lat": { "type": "number" }, "lng": { "type": "number" } },
      "description": "The coarsened public point: the county's middle, or rounded to 2 decimals (about 1 km), unless exact_consented"
    },
    "location_precision": { "enum": ["county", "approximate", "exact_consented"] },
    "photos": { "type": "array", "items": { "type": ["string", "object"] } },
    "contributor": { "type": "string", "description": "Display name only" },
    "org": { "type": "string" },
    "source": { "enum": ["user", "official_import"] },
    "license": { "type": "string" },
    "published_at": { "type": "string", "format": "date" },
    "updated_at": { "type": "string", "format": "date" },
    "example": { "type": "boolean", "description": "true for illustrative records that are not real offerings" },
    "url": { "type": "string", "format": "uri" }
  },
  "not": { "anyOf": [ { "required": ["email"] }, { "required": ["phone"] }, { "required": ["address"] }, { "required": ["location"] } ] }
}
