Document extraction with validation
Extract structured fields while preserving the source and deterministic checks.
Purpose
Extract structured fields while preserving the source and deterministic checks. The workflow is acceptable only while its evidence, permission, review, and stop boundaries remain true.
Prerequisites
- A typed output schema with required fields and formats.
- A tested set of document layouts; anything outside it goes to manual handling.
- A staging area separate from the system of record.
Worked example
Source snippet (fictional invoice, page 1).
Invoice INV-20431 Date: 03/10/2026
Supplier: Northwind Parts Ltd
Brake pads x4 120.00
Fitting 35.00
Subtotal 155.00 VAT 31.00 Total 186.00
Typed staging record.
{
"source": { "file": "inv-20431.pdf", "page": 1 },
"invoiceNumber": "INV-20431",
"invoiceDate": "2026-10-03",
"dateFormat": "DD/MM/YYYY (supplier profile)",
"supplier": "Northwind Parts Ltd",
"lineTotals": ["120.00", "35.00"],
"subtotal": "155.00",
"tax": "31.00",
"total": "186.00",
"status": "staged"
}
Procedure
- Define the schema, including decimal amounts as strings and the date format for each supplier.
- Extract into a staging record that keeps the source file and page; never write to the ledger directly.
- Run deterministic checks on every record and set the status to passed or rejected with a reason code.
- Send rejected records and a written sample of passed records to the reviewer with the source page.
- Post only passed and reviewed records through the ordinary import step.
Deterministic and review checks
- Required fields present; amounts parse as decimals; dates are valid and not in the future.
- Line totals sum to the subtotal, and subtotal plus tax equals the total.
- The invoice number is not already staged or posted for this supplier.
- An ambiguous date such as 03/10 is resolved only by the supplier profile, otherwise rejected.
A case that must fail
If the model reads the total as 168.00, subtotal plus tax (186.00) no longer matches. The record is rejected with reason total_mismatch and is never posted.
Human boundary
A reviewer resolves every rejected record against the source and owns the sample result. Extraction never overwrites source documents or approves payment.
Stop and escalation
- Do not overwrite source records.
- Stop when layout or handwriting falls outside the tested set.