ConstraintMappings to validator factory.
A constraint mapping contributor can be configured in META-INF/validation.xml, using the property
org., thus allowing to set
up constraints to be validated by default validators dynamically via the API for programmatic constraint declaration.
Implementations must have a no-args constructor.
One or more mappings can be added as shown in the following:
public static class MyConstraintMappingContributor implements ConstraintMappingContributor {
public void createConstraintMappings(ConstraintMappingBuilder builder) {
builder.addConstraintMapping()
.type( Marathon.class )
.property( "name", METHOD )
.constraint( new NotNullDef() )
.property( "numberOfHelpers", FIELD )
.constraint( new MinDef().value( 1 ) );
builder.addConstraintMapping()
.type( Runner.class )
.property( "paidEntryFee", FIELD )
.constraint( new AssertTrueDef() );
}
}
org.hibernate.validator.HibernateValidatorConfiguration#CONSTRAINT_MAPPING_CONTRIBUTORS
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ConstraintMappingContributor.ConstraintMappingBuilder
A builder for adding constraint mappings. |
| Modifier and Type | Method and Description |
|---|---|
| public void | createConstraintMappings(ConstraintMappingContributor.
A builder for adding one or more constraint mappings builderCallback invoked during validator factory creation. |
| createConstraintMappings | back to summary |
|---|---|
| public void createConstraintMappings(ConstraintMappingContributor. Callback invoked during validator factory creation. Any constraint mapping configured via the passed builder will be added to the mappings of the factory.
| |
| Modifier and Type | Method and Description |
|---|---|
| public ConstraintMapping | Returns: The constraint mapping for further configuration via the fluent API.Adds a new constraint mapping. |
| addConstraintMapping | back to summary |
|---|---|
| public ConstraintMapping addConstraintMapping() Adds a new constraint mapping.
| |