Class ConstrainedBean

java.lang.Object
rife.validation.ConstrainedBean

public class ConstrainedBean extends Object
A ConstrainedBean object makes it possible to define all constraints for a bean instance that are not related to a single property. The constraints here are global for the entire bean and either involve several properties or are even totally unrelated to properties.

It's possible to add constraints to a ConstrainedBean instance through regular setters, but chainable setters are also available to make it possible to easily define a series of constraints, for example:

var constrained = new ConstrainedBean()
    .unique("firstName", "lastName")
    .defaultOrder("city")
    .defaultOrder("lastName")
    .defaultOrder("firstName");

A constrained bean is typically added to a Constrained bean in its constructor. These are the static constraints that will be set for each and every instance of the bean. You'll however most of the time use the Validation abstract class that provides the activateValidation method which initializes the constraints on a need-to-have basis. This dramatically reduces memory usage since otherwise all constraints will be initialized for every bean instance, even though you don't use them.

Since:
1.0
See Also: