public interface ConstraintMappingContributor
ConstraintMappings to validator factory.
A constraint mapping contributor can be configured in META-INF/validation.xml, using the property
HibernateValidatorConfiguration.CONSTRAINT_MAPPING_CONTRIBUTOR, 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() );
}
}
HibernateValidatorConfiguration.CONSTRAINT_MAPPING_CONTRIBUTOR| Modifier and Type | Interface and Description |
|---|---|
static interface |
ConstraintMappingContributor.ConstraintMappingBuilder
A builder for adding constraint mappings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
createConstraintMappings(ConstraintMappingContributor.ConstraintMappingBuilder builder)
Callback invoked during validator factory creation.
|
void createConstraintMappings(ConstraintMappingContributor.ConstraintMappingBuilder builder)
builder - A builder for adding one or more constraint mappingsCopyright © 2018 JBoss by Red Hat. All rights reserved.