Model Validations

Latest release: 2.0.2

Validate your NS models.



See Creating rules for creating custom rules.

Rules provided by expansion-resources

The validation rules are packaged as expansion-resources. These resources need to be added to your expansionSettings.xml to use them to validate your model.

E.g. to add basic validations for a standard NS application:

    <expansionResource name="net.democritus.validations.model:prime-validations" version="2.0.2"/>

Command Line Usage

1. Grab the latest release version.

mvn -U dependency:copy "-Dartifact=net.democritus.model:model-validations:RELEASE:jar:jar-with-dependencies" "-DoutputDirectory=." "-Dmdep.stripVersion=true" "-Dmdep.stripClassifier=true"

2. Ask the CLI for help.

java -jar model-validations.jar --help

3. Run on your project with all report formats.

java -jar model-validations.jar `
    --expansionSettings conf/expansionSettings.xml `
    --stdout `
    --html target/validation-report.html `
    --junit target/validation-report.xml

4. Filter Reports

If you want to suppress rules, specific elements, or specific issues.

Create conf/validation.xml file to define your excludes.

<validation xmlns="">
      <!-- glob against rule className -->
      <!-- no elements specified, ignore all -->

      <!-- glob against rule className -->
        <!-- DataRef; exact match, no pattern/glob -->

      <!-- rule can produce multiple issues for the same element -->
        <!-- issue full message; exact match, no pattern/glob -->
        <!-- encode angle brackets or use CDATA -->
        <issue>&lt;Finder elements::Application::findByComponentEq&gt; is missing</issue>


Re-run validation. The file conf/validation.xml will be automatically picked up.

Jenkins Usage

Example stage in Jenkins.

stage('validate') {
  steps {
    // [recommended] when using `conf/expansionSettings.xml`
    // alternatively 
    modelValidations expansionSettings: 'conf/I-like-to-complicate-my-life-expansionSettings.xml'
    // (optional) capture generated junit report
    junit 'target/validation/report.xml'

    // (optional) publish generated HTML report (until we have better integration)
    publishHTML target: [
        reportDir: "target/validation",
        reportFiles: "index.html",
        reportName: 'Model Validation Report',
        keepAll: true,
        alwaysLinkToLastBuild: true,
        allowMissing: true,

Maven Usage

You can run the validations with the expanders-maven-plugin (version 2022.0.1 and up):

mvn -f pom-expand.xml expanders:validate-model --Dvalidation.html=report.html -Dvalidation.junit=report.xml =Dvalidation.print=true

You can also configure the plugin in the pom-expand.xml:


Output Formats


[validator] --stdout


  - deprecation:
    - Deprecated:
      - net.democritus.elements.validations.FieldIsStatusFieldRule:
          reason: Status field will be determined using "isStatusField" option only. Fields with name "status" and type "String" should contain "isStatusField" option to preserve functionality.
          description: Status field will be determined using "isStatusField" option only. Fields with name "status" and type "String" should contain "isStatusField" option to preserve functionality.
            - <Field atodoComp::Duration::status> is missing "isStatusField" option
            - <Field atodoComp::TaskAssignment::status> is missing "isStatusField" option


JUnit-compatible XML report file.

[validator] --junit target/validation-report.xml


Custom html validation report.

[validator] --html target/validation-report.html