= Domain Model Validator
:page-role: -toc

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Domain model validation checks for various semantic errors that might exist within the domain model.

Running up the application will flag any validation issues, as will running an integration test.
However, depending upon configuration, the metamodel may only be built lazily, meaning that issues would only be detected while the application is running, rather than at bootstrap.

The xref:refguide:testing:index/integtestsupport/applib/validate/DomainModelValidator.adoc[DomainModelValidator] is a simple utility class that will fully rebuild the metamodel if required, and can then be used to verify that there are no issues.

The example below is taken from the xref:docs:starters:simpleapp.adoc[simpleapp] starter app:

[source,java]
.ValidateDomainModel_IntegTest.java
----
class ValidateDomainModel_IntegTest
        extends ApplicationIntegTestAbstract {

    @Inject ServiceRegistry serviceRegistry;

    @Test
    void validate() {
        new DomainModelValidator(serviceRegistry).assertValid();
    }
}
----

To see this in action:

* change the `isis.applib.annotation.action.explicit` configuration property to `false` in `application.yml`
* introduce an error, for example by renaming `default0UpdateName` to `default0UpdateFoo`.
* run the test

