container.setEmail( email );
Set<ConstraintViolation<EmailContainer>> violations = validator.validate( container );
assertOrgAddressesAreNotValid( violations );
// now the same test with programmatic configuration
final HibernateValidatorConfiguration config = getConfiguration( HibernateValidator.class );
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type( EmailContainer.class )
.property( "email", METHOD )
.constraint(
new EmailDef().regexp( noOrgEmailAddressRegexp )
.message( "ORG addresses are not valid" )
);
config.addMapping( mapping );
validator = config.buildValidatorFactory().getValidator();
container = new EmailContainerNoAnnotations();
container.setEmail( email );
violations = validator.validate( container );
assertOrgAddressesAreNotValid( violations );