Validate a configuration type
Each configuration file is validated against a schema specific to its configuration type. Example: events, which, in earlier Commerce versions, were configured in config.xml
, are now configured in events.xml
.
Configuration files can be validated both before (optional) and after any merge of multiple files affecting the same configuration type. Unless the validation rules for the individual and merged files are identical, you should provide two schemas for validating the configuration files:
- Schema to validate an individual
- Schema to validate a merged file
New configuration files must be accompanied by XSD validation schemas. An XML configuration file and its XSD validation file must have the same name.
If you must use two XSD files for a single XML file, the names of the schemas should be recognizable and associated with the XML file.
If you have an events.xml
file and a first events.xsd
file, the XSD files for the merged events.xml
file could be named events_merged.xsd
.
To ensure validation of an XML file by appropriate XSD file, you must add the Uniform Resource Name (URN) to the XSD file in the XML file. For example:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager:etc/config.xsd">
Your IDE can validate your configuration files at both runtime and during development.