{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://standard-barcodeverified.org/protocol/match-record.schema.json",
 "title": "Match record · AI Product Match Verification 0.1",
 "type": "object",
 "required": [
  "id",
  "time",
  "words",
  "kind",
  "country",
  "outcome",
  "confidence",
  "matcher_kid",
  "match_hash",
  "core_version"
 ],
 "properties": {
  "id": {
   "type": "string"
  },
  "time": {
   "type": "string",
   "format": "date-time"
  },
  "words": {
   "type": "string",
   "minLength": 1
  },
  "kind": {
   "enum": [
    "phrase",
    "offer"
   ]
  },
  "country": {
   "type": "string",
   "pattern": "^[A-Z]{2}$",
   "not": {
    "const": "GB"
   }
  },
  "barcode": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^[0-9]{14}$"
  },
  "confidence": {
   "type": "number",
   "minimum": 0,
   "maximum": 1
  },
  "outcome": {
   "enum": [
    "one",
    "ambiguous",
    "unknown"
   ]
  },
  "candidates": {
   "type": "array",
   "items": {
    "type": "string",
    "pattern": "^[0-9]{14}$"
   }
  },
  "result": {
   "enum": [
    "verified",
    "listed",
    "stale",
    "unknown",
    null
   ]
  },
  "matcher_kid": {
   "type": "string"
  },
  "core_version": {
   "type": "string"
  },
  "profile_version": {
   "type": "string"
  },
  "match_hash": {
   "type": "string",
   "pattern": "^sha256:[0-9a-f]{64}$"
  }
 },
 "allOf": [
  {
   "if": {
    "properties": {
     "outcome": {
      "const": "one"
     }
    }
   },
   "then": {
    "required": [
     "barcode"
    ],
    "properties": {
     "barcode": {
      "type": "string"
     }
    }
   }
  },
  {
   "if": {
    "properties": {
     "outcome": {
      "const": "ambiguous"
     }
    }
   },
   "then": {
    "required": [
     "candidates"
    ],
    "properties": {
     "candidates": {
      "minItems": 2
     },
     "barcode": {
      "type": "null"
     }
    }
   }
  }
 ]
}