Tamaya Validation: Validating Configuration (Extension Module)

Tamaya Validation is an extension module. Refer to the extensions documentation for further details.


Tamaya Validation adds support to validate a configuration against a set of rules defined in a Tamaya Metaconfiguration XML file.


The module is based on Java 8.


To activate configuration validation you only must add the corresponding dependency to your module:


The component will extend Tamaya’s tamaya-metamodel module and adds an additional meta provider ruleset so validation rules can also be added to the default meta configuration XML file as separate sections.


This module expects meta-configuration to be located at the following locations. Hereby multiple files are supported:

-Dtamaya-validation=<an URL>    // any resolvable URL
./tamaya-validation-*.xml         // file
META-INF/tamaya-validation-*.xml  // classpath (multiple entries-possible)

The Validation XML Format

The configuration validation is defined by simple configuration meta-data entries.

   <provider>The Validation Provider</provider> <!-- optional -->
   <section name="org.mycompany">
       <section name="security" required="true">
         <description>The description of ma area.</description>
   <section name="minimal"/>
   <section name="validated.sections" at-least="1">
     <section name="customValidated" validator="myFQValidatorClassName"/>
     <section name="withParams" >
       <param name="int" type="int"/>
       <param name="aText" expression="[a|b|c]" required="true"/>
       <param name="aValidatedText" validator="myValidatorClass">
         <description>This kind of params are more complex...</description>
   <validator class="a,b,c,MyGlobalValidator"/>

The Example Explained

  • The provider entry is used for generating validation message, when a validation fails.

  • Section itself can be recursively defined, where each level can have it’s own validations.

  • Sections added, but without validation rules are defined section. Configuration outside of defined sections can be flagged out using WARNING messages.

  • Sections can be reuired and additionally also validated.

  • There is also the possibility to register global validators, which are called by the validation logic once a configuration has been completely loaded.

Similar to sections also parameters can be validated:

  • they can be marked as required

  • they can have a certain type, meaning they must be convertible to the given type

  • they can have an additional custom validator.

  • they can have an optional description for error analysis and error output.

Similar to section parameters that are not defined, but encountered may be flagged out with a WARNING message.