CFDI 4.0 introduced significant changes to Mexico’s electronic invoicing standard, and CfdiUtils reflects those changes in its validation pipeline. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/eclipxe13/CfdiUtils/llms.txt
Use this file to discover all available pages before exploring further.
CfdiValidator40 class and the associated MultiValidatorFactory::newCreated40() / newReceived40() methods configure a dedicated validator set for CFDI 4.0 documents. While many of the underlying business rules are similar to the 3.3 validators, there are important additions and modifications you need to be aware of when working with CFDI 4.0 documents.
All validation messages remain in Spanish, consistent with the SAT’s own terminology. The four-status system (OK, ERROR, WARN, NONE) and the mustStop behavior are identical to CFDI 3.3 — see the Validation Overview for a full explanation of the architecture.
Validating CFDI 4.0 Documents
Received documents
Created documents
New Validators in CFDI 4.0
CFDI 4.0 introduces two validators that do not exist in the 3.3 pipeline.XmlDefinition
This validator runs immediately after XmlFollowSchema and checks CFDI 4.0-specific structural requirements that are not covered by the XSD alone. It verifies three things: the correct SAT namespace for CFDI 4.0, the root element name, and the version attribute.
The expected namespace is http://www.sat.gob.mx/cfd/4.
| Code | Title |
|---|---|
XML01 | El XML implementa el namespace http://www.sat.gob.mx/cfd/4 con el prefijo cfdi |
XML02 | El nodo principal se llama cfdi:Comprobante |
XML03 | La versión es 4.0 |
These three rules make
XmlDefinition a prerequisite guard for CFDI 4.0 processing. If a document uses the CFDI 3.3 namespace or declares version 3.3, all three codes will fail. Ensure your XML declares the correct namespace before submitting it for full validation.Validators Shared with CFDI 3.3 (with Differences)
Several validators exist in both the 3.3 and 4.0 pipelines but have meaningful behavioral differences in CFDI 4.0.SelloDigitalCertificado — Updated name-matching logic
The digital seal validator runs the same eight checks (SELLO01–SELLO08) in both versions, but CFDI 4.0 introduces a change in how SELLO04 (issuer name) is evaluated:
| Version | Persona Moral (12-char RFC) | Persona Física (13-char RFC) |
|---|---|---|
| CFDI 3.3 | Name comparison is optional; an empty name is silently accepted | Name is compared if non-empty |
| CFDI 4.0 | Régimen de capital suffix is stripped before comparing; an empty name causes an error | An empty name causes an error |
| Code | Title |
|---|---|
SELLO01 | Se puede obtener el certificado del comprobante |
SELLO02 | El número de certificado del comprobante igual al encontrado en el certificado |
SELLO03 | El RFC del comprobante igual al encontrado en el certificado |
SELLO04 | El nombre del emisor del comprobante es igual al encontrado en el certificado |
SELLO05 | La fecha del documento es mayor o igual a la fecha de inicio de vigencia del certificado |
SELLO06 | La fecha del documento menor o igual a la fecha de fin de vigencia del certificado |
SELLO07 | El sello del comprobante está en base 64 |
SELLO08 | El sello del comprobante coincide con el certificado y la cadena de origen generada |
TimbreFiscalDigitalSello — SAT stamp integrity
Identical behavior to CFDI 3.3. This remains the most critical validator: it fetches the SAT certificate, builds the TFD cadena de origen, and verifies the SAT seal.
| Code | Title |
|---|---|
TFDSELLO01 | El Sello SAT del Timbre Fiscal Digital corresponde al certificado SAT |
TimbreFiscalDigitalVersion — TFD version
Identical behavior to CFDI 3.3.
| Code | Title |
|---|---|
TFDVERSION01 | Si existe el complemento timbre fiscal digital, entonces su versión debe ser 1.1 |
Differences from CFDI 3.3
The table below summarizes the key differences between the two validator pipelines.| Area | CFDI 3.3 | CFDI 4.0 |
|---|---|---|
| XML namespace | http://www.sat.gob.mx/cfd/3 (enforced via XSD) | http://www.sat.gob.mx/cfd/4 — also explicitly checked by XmlDefinition (XML01) |
| Root element check | XSD only | XmlDefinition explicitly verifies cfdi:Comprobante (XML02) |
| Version attribute | XSD only | XmlDefinition explicitly verifies Version = 4.0 (XML03) |
| Issuer name (SELLO04) | Empty name is silently accepted for both RFC types | Empty name causes an error; persona moral removes capital suffix before comparing |
| RecepcionPagos validators | Full set of PAGO*, COMPPAG*, PAGREL*, PAGUSO*, PAGCON* codes | Not present in the 4.0 standard validator set (Complemento Pagos 2.0 has its own validation path) |
| Factory method | MultiValidatorFactory::newCreated33() / newReceived33() | MultiValidatorFactory::newCreated40() / newReceived40() |
| Discoverer source directory | Cfdi33/Standard + Cfdi33/RecepcionPagos | Cfdi40/Standard |
| Validator class | CfdiValidator33 | CfdiValidator40 |
| Creator class | CfdiCreator33 | CfdiCreator40 |
Validator Pipeline Order
Understanding the execution order helps diagnose partial validation results.XmlFollowSchema (XSD01)
Validates the document against all declared XSD schemas. Sets
mustStop on failure — no further validators run.XmlDefinition (XML01–XML03)
Checks CFDI 4.0-specific namespace, root element name, and version. Runs after schema validation.
Complete CFDI 4.0 Validation Code Reference
| Code | Validator | Title |
|---|---|---|
XSD01 | XmlFollowSchema | El contenido XML sigue los esquemas XSD |
XML01 | XmlDefinition | El XML implementa el namespace http://www.sat.gob.mx/cfd/4 con el prefijo cfdi |
XML02 | XmlDefinition | El nodo principal se llama cfdi:Comprobante |
XML03 | XmlDefinition | La versión es 4.0 |
SELLO01 | SelloDigitalCertificado | Se puede obtener el certificado del comprobante |
SELLO02 | SelloDigitalCertificado | El número de certificado del comprobante igual al encontrado en el certificado |
SELLO03 | SelloDigitalCertificado | El RFC del comprobante igual al encontrado en el certificado |
SELLO04 | SelloDigitalCertificado | El nombre del emisor del comprobante es igual al encontrado en el certificado |
SELLO05 | SelloDigitalCertificado | La fecha del documento es mayor o igual a la fecha de inicio de vigencia del certificado |
SELLO06 | SelloDigitalCertificado | La fecha del documento menor o igual a la fecha de fin de vigencia del certificado |
SELLO07 | SelloDigitalCertificado | El sello del comprobante está en base 64 |
SELLO08 | SelloDigitalCertificado | El sello del comprobante coincide con el certificado y la cadena de origen generada |
TFDSELLO01 | TimbreFiscalDigitalSello | El Sello SAT del Timbre Fiscal Digital corresponde al certificado SAT |
TFDVERSION01 | TimbreFiscalDigitalVersion | Si existe el complemento timbre fiscal digital, entonces su versión debe ser 1.1 |
See Also
Validation Overview
Architecture, statuses, mustStop behavior, and complete usage examples.
Standard CFDI 3.3 Rules
Full reference for all CFDI 3.3 standard and RecepcionPagos validators.