validate_fattura_xsd
Validates a FatturaPA XML string against the official Agenzia delle Entrate XSD schema v1.6.1, ensuring correct namespace, element structure, data types, and cardinality constraints. Returns validation results or errors.
Instructions
Validate a FatturaPA XML string against the official Agenzia delle Entrate XSD v1.6.1.
Use this as step 11 — always call immediately after generate_fattura_xml() before storing or transmitting the document. Also use to verify third-party invoices received from suppliers.
Requires lxml to be installed and the bundled XSD schema file to be present (or FATTURA_XSD_PATH env var to point to it). Validates namespace, element structure, data types, and cardinality constraints.
On success returns {'valid': true, 'formato_trasmissione': 'FPR12'|'FPA12', 'errors': []}. On failure returns {'valid': false, 'errors': ['', ...]}. On setup error (missing lxml or XSD file) returns {'error': ''}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| xml_string | Yes | Complete FatturaPA XML string to validate. Must include the FatturaElettronica root element with the correct namespace (http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||