OVal is the simple validation framework for Java. You can specify validation rules using annotations.
public class Person { @NotNull public String name; }
Usage:
Validator v = new Validator(); Person p = new Person(); for(ConstraintViolation error: v.validate(p)){ System.out.println(error.getMessage()); }OVal can switch validation rules by profiles.
public class Person { @NotNull(profiles={"profile1"}) public String name; @NotNull(profiles={"profile1", "profile2"}) public String email; }
Switch profiles like following:
// Enable all profiles v.enableAllProfiles(); // Enable a specified profile v.enableProfile("profile1"); // Disable all profiles v.disableAllProfiles(); // Disable a specified profile v.disableProfile("profile1");
0 件のコメント:
コメントを投稿