Add optional XSD validation - #256
Merged
BorislavSabev merged 1 commit intoSep 14, 2026
Merged
Conversation
BorislavSabev
requested review from
BenjaminPaap and
monofone
as code owners
September 14, 2026 12:57
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Added
BaseDomBuilder::validateSchema(?string $xsdFile = null): bool— validates the generated XML against an XSD. Defaults to the ISO 20022 XSD bundled for the builder's pain format; pass a path to validate against a bank's variant XSD.BaseDomBuilder::getSchemaValidationErrors(?string $xsdFile = null): array— same, but returns oneLine N: messagestring per error; empty when the document is valid.BaseCustomerTransferFileFacade. They render the document first, with the same single-shot semantics asasXML().MessageFormat::getBundledSchemaPath(): ?string— path to the bundled XSD for a format, ornullwhen none is bundled.tests/Unit/DomBuilder/SchemaValidationTest.php— 52 tests: every supported format has a bundled XSD matching the test fixture, valid SCT/SDD files pass for every pain.001.001.x / pain.008.001.x version, errors are reported, explicit paths are used, exceptions for missing XSDs, libxml state is restored, and the facade passthroughs.Changed
ext-libxmlmoved fromrequire-devtorequire;BaseDomBuildernow callslibxml_*functions.doc/guides/output-and-validation.mdno longer claims the XSDs aren't shipped and documents the new methods; DomBuilder, facade and exceptions reference pages updated.Notes
doc/ISO20022/. A test fails if.gitattributesever excludes that directory.asDoc()directly always fails, because the root'sxmlnsis set as an attribute and the in-memory elements aren't in the schema's namespace.setOmitAgentElementIfBicMissing(true)can fail the base ISO XSD (it drops mandatoryDbtrAgt/CdtrAgt). Validate those against the bank's own XSD.InvalidArgumentExceptionis thrown when the XSD path doesn't exist, or when no XSD is bundled for the format and none was passed.DomBuilderInterfaceorCustomerTransferFileFacadeInterface, so custom implementations don't break.