Hi bquenin,
Sorry for the late reply, we were all in year's end holiday mode :)
Hibernate Validator provides an API for programmatic constraint declaration (http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-programmatic-api) which allows to declare constraints using Java ("internal DSL") like this:
Code:
ConstraintMapping constraintMapping = ...;
constraintMapping
.type( Car.class )
.property( "manufacturer", FIELD )
.constraint( new NotNullDef() )
.property( "licensePlate", FIELD )
.ignoreAnnotations()
.constraint( new NotNullDef() )
.constraint( new SizeDef().min( 2 ).max( 14 ) )
.type( RentalCar.class )
.property( "rentalStation", METHOD )
.constraint( new NotNullDef() );
//... bootstrap validator using mapping
There is no support for external constraint languages such as OCL (besides the XML descriptors), but it should be possible to implement an OCL parser based on the programmatic API. Personally I feel this shouldn't be part of HV core as its quite specific and would probably not be used by many people.
Out of interest, what is your use case for using OCL instead of the means of constraint declaration provided by Bean Validation and HV (annotations, XML and API)?
--Gunnar