Validate Fattura Xsd
validate_fattura_xsdValidate FatturaPA XML against official Agenzia delle Entrate XSD v1.2.3, automatically selecting FPR12 or FPA12 schema by version attribute. Returns validity and detailed errors to ensure compliance before transmission.
Instructions
Validate a FatturaPA XML string against the official Agenzia delle Entrate XSD v1.2.3.
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.
Automatically selects the correct XSD based on the document's versione attribute:
FPR12 (B2B/B2C) uses FatturaPA_FPR12_v1.2.3.xsd; FPA12 (B2G) uses
FatturaPA_FPA12_v1.2.3.xsd. FATTURA_XSD_PATH env var overrides both.
Requires lxml. Validates namespace, element structure, data types, and cardinality.
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 | |||