I am using hibernate validator in my spring mvc app. With the following simple steps I am able to get the validation happen.
pom.xmlchanges to add hibernate validator.- Annotated the beans with some constraints.
- Annotated the controller method parameter with
@Valid. - Handled the
MethodArgumentNotValidException
I don't want to add the constraints to the beans, instead want to add them to the beans dynamically. This dynamic addition need to happen during application startup and just once.
In the hibernate validator documentation, I see the following snippet.
constraintMapping.type( Car.class ).property( "manufacturer", FIELD ).constraint( new NotNullDef() )
My question is, how do I get a handle to this ConstraintMapping instance ? I see that Spring instantiates the hibernate validator through the LocalValidatorFactoryBean.
thanks for your help.