|
|
|
Hibernate Validator has an API which allows to dynamically configure constraints:
{code} ConfigurationMapping mapping = ...; constraintMapping .type( Car.class ) .property( "manufacturer", FIELD ) .constraint( new NotNullDef() ); {code}
Java 8 allows to reference methods in a safe manner, which could be used instead of string-based property names when navigating to a bean property:
{code} constraintMapping .type( Car.class ) .property( Car::getManufacturer ) .constraint( new NotNullDef() ); {code}
Unfortunately this only works for getter properties, not fields. Not sure whether it's really that useful in the end, but it's worth playing around with it and see how it works out.
|
|
|
|