dOOv, a fluent API for type-safe domain model validation
Java Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

dOOv (Domain Object Oriented Validation)

Build Status Build status

dOOv is a fluent API for typesafe domain model validation. It uses annotations, code generation and a type safe DSL to make domain model validation fast and easy.

dOOv logo


See the getting started section in the wiki, or see the small usage overview.


See the the sample project in dOOv. It contains two model domains, maven and gradle code generation, and example rules.


See our presentation slides at JDK.IO.

See our presentation slides at Oracle Code.

See our presentation slides about the implementation of failure cause at Sorbonne University.



Annotate your model with @Path annotations on field, qualifying them with field ids (see wiki section Domain Model Annotation)

public class User {

    @SamplePath(field = SampleFieldId.FIRST_NAME, readable = "user first name")
    private String firstName;

    @SamplePath(field = SampleFieldId.LAST_NAME, readable = "user last name")
    private String lastName;

    @SamplePath(field = SampleFieldId.BIRTHDATE, readable = "user birthdate")
    private LocalDate birthDate;


Use the dOOv code genrator to generate a DSL with elements userFirstName, userLastName and userBirthDate (see wiki section DSL Code Generation). Then write your rules with entry point DOOV#when and terminal operation ValidationRule#validate (see wiki section Validation Rules).

ValidationRule rule = DOOV.when(userBirthdate().ageAt(today()).greaterOrEquals(18))

You can create more complex rules by chaining and and or or by using matching methods from the DOOV class like matchAny, etc.


You can then execute the rule on an instantiated model (see wiki section Validation Engine).

// Execute the DSL on the model
DslModel model = new SampleModelWrapper(sampleModel);
Result result = rule.executeOn(model);
if (result.isFalse()) {

The result will return true or false depending on the result of the predicate, for example Result#isTrue means the predicate validated.

Syntax tree

The rules provides an AST that can be printed as a human readable format with the Readable#readable method that is available on any DSL object. By default the output is from AstLineVisitor that outputs the string in plain text (see wiki section Validation Engine).

> When user age at 'today' greater or equals '18', validate with empty message


Assertions are available in the doov-assertions jar. It depends on AssertJ, so you can use the assertThat syntax (see wiki section Testing Rules).

ValidationRule rule = DOOV.when(userFirstName().isNotNull().or(userLastName().isNull())).validate();


To build core, assertions, generator core, maven generator plugin and gradle generator plugin modules:

# Core
./gradlew build

# Sample modules with examples
./gradlew -p sample build

To deploy you need to configure the command line options for your repository:

./gradlew \
  -Psigning.secretKeyRingFile=secret-file.gpg \
  -Psigning.keyId=key-id \
  -Psigning.password=password \
  -PsnapshotRepository= \
  -Prepository= \
  -PossrhUsername=userName \
  -PossrhPassword=password \

You can either specify snapshotRepository or repository depending on the version type.

To generate documentation with gradle:

# Generate documentation in docs/site/apidocs/subproject
./gradlew javadoc


To release the code, it will create 2 commits with proper tags and versions and push them:

./gradlew \
  -Psigning.secretKeyRingFile=secret-file.gpg \
  -Psigning.keyId=key-id \
  -Psigning.password=password \
  -PsnapshotRepository= \
  -Prepository= \
  -PossrhUsername=userName \
  -PossrhPassword=password \
  -Pversions.newVersion=RELEASE_VERSION \