code
docs
tests
The Constraints library provide a bunch of often used Constraints based on the Zest™ Constraints api described in Constraint.
Remember that you are not limited to constraints presents in this library, you are encouraged to write your own constraints. See Create a Constraint or take a look at this library source code to learn how to write your own.
You can use theses constraints on Properties or on method arguments. Here are some examples:
import org.qi4j.library.constraints.annotation.*; [...snip...] @Contains( "foo" ) Property<String> containsString(); @Email Property<String> email(); @URL Property<String> url(); @URI Property<String> uri(); @GreaterThan( 10 ) Property<Integer> greaterThan(); @InstanceOf( List.class ) Property<Collection> instanceOf(); @LessThan( 10 ) Property<Integer> lessThan(); @Matches( "a*b*c*" ) Property<String> matches(); @MaxLength( 3 ) Property<String> maxLength(); @MinLength( 3 ) Property<String> minLength(); @NotEmpty Property<String> notEmptyString(); @NotEmpty Property<Collection> notEmptyCollection(); @NotEmpty Property<List> notEmptyList(); @Range( min = 0, max = 100 ) Property<Integer> range(); @OneOf( { "Bar", "Xyzzy" } ) Property<String> oneOf(); void testParameters( @GreaterThan( 10 ) Integer greaterThan );