}
@Test
@TestForIssue(jiraKey = "HV-812")
public void testProgrammaticMod11Constraint() {
final HibernateValidatorConfiguration config = getConfiguration( HibernateValidator.class );
ConstraintMapping mapping = config.createConstraintMapping();
mapping.type( Product.class )
.property( "productNumber", FIELD )
.constraint(
new Mod11CheckDef()
.threshold( Integer.MAX_VALUE )
.startIndex( 0 )
.endIndex( 12 )
.ignoreNonDigitCharacters( true )
.treatCheck10As( 'X' )
.treatCheck11As( 'P' )
.processingDirection( ProcessingDirection.LEFT_TO_RIGHT )
);
config.addMapping( mapping );
Validator validator = config.buildValidatorFactory().getValidator();
Product product = new Product( "123-456-789-P" );
Set<ConstraintViolation<Product>> constraintViolations = validator.validate( product );
assertNumberOfViolations( constraintViolations, 0 );