baodan/docs/schemas/field-value.schema.json

71 lines
2.2 KiB
JSON
Raw Normal View History

2026-08-02 12:58:41 +08:00
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://baodan.example/schemas/field-value-v1.json",
"title": "Insurance FieldValue v1",
"type": "object",
"additionalProperties": false,
"required": ["status", "value", "evidence"],
"properties": {
"status": {
"enum": ["missing", "extracted", "conflict", "confirmed", "derived"]
},
"value": {
"type": ["string", "number", "integer", "boolean", "null"]
},
"currency": {
"type": ["string", "null"],
"enum": ["USD", "HKD", "CNY", "SGD", "EUR", "GBP", null]
},
"unit": {"type": ["string", "null"]},
"confidence": {"type": ["number", "null"], "minimum": 0, "maximum": 1},
"evidence": {
"type": "array",
"items": {"$ref": "#/$defs/evidenceRef"}
},
"derivedBy": {"type": ["string", "null"]},
"overrideReason": {"type": ["string", "null"], "minLength": 1},
"conflictCandidates": {
"type": "array",
"items": {"type": ["string", "number", "integer", "boolean", "null"]}
}
},
"allOf": [
{
"if": {"properties": {"status": {"const": "missing"}}},
"then": {"properties": {"value": {"type": "null"}}}
},
{
"if": {"properties": {"status": {"const": "derived"}}},
"then": {"required": ["derivedBy"]}
},
{
"if": {"required": ["overrideReason"]},
"then": {"properties": {"status": {"const": "confirmed"}}}
}
],
"$defs": {
"evidenceRef": {
"type": "object",
"additionalProperties": false,
"required": ["documentId", "pageNumber"],
"properties": {
"documentId": {"type": "integer", "minimum": 1},
"pageNumber": {"type": "integer", "minimum": 1},
"bbox": {
"type": ["array", "null"],
"prefixItems": [
{"type": "number"}, {"type": "number"},
{"type": "number"}, {"type": "number"}
],
"minItems": 4,
"maxItems": 4
},
"tableId": {"type": ["string", "null"]},
"rowId": {"type": ["string", "null"]},
"columnId": {"type": ["string", "null"]},
"textHash": {"type": ["string", "null"], "pattern": "^[0-9a-f]{64}$"}
}
}
}
}