-
Notifications
You must be signed in to change notification settings - Fork 16
Validation Rules
ozangunalp edited this page Aug 2, 2018
·
5 revisions
See latest version in maven central.
Maven
<!-- The dependency for doov -->
<dependency>
<groupId>io.doov</groupId>
<artifactId>doov-code</artifactId>
<version>LATEST</version>
</dependency>
<!-- The dependency on your generated DSL (see previous step) -->
<dependency>
<groupId>io.doov</groupId>
<artifactId>doov-sample-generated</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>Gradle
dependencies {
compile project(':doov-sample-generated')
}This documentation is based on the sample project in
dOOv. You can replace
the package name io.doov.sample by your package name as com.example.myapp
and classes name Sample with MyApp.
As the entry point you can either use io.doov.dsl.DOOV which is generic and
do not depend on the type of your model, or the generated class
io.doov.sample.field.dsl.DslSampleModel.
package io.doov.sample.validation;
import static io.doov.sample.field.dsl.DslSampleModel.accountEmail;
public interface SampleRules {
// Generic way of writing a rule
ValidationRule RULE_EMAIL_GENERIC = DOOV
.when(accountEmail.matches("\\w+[@]\\w+\\.com"))
.validate();
// Typed way of writing a rule (makes execution more streamlined)
ModelStepWhen RULE_EMAIL = DslModel
.when(accountEmail.matches("\\w+[@]\\w+\\.com"))
.validate();
}- Boolean Rules for boolean validation (not, and, or, etc.)
- String Rules for string validation (matches, length, etc.)