Skip to content
Advertisement

Manually call Spring Annotation Validation

I’m doing a lot of our validation with Hibernate and Spring Annotations like so:

JavaScript

And then in the controller it’s called in the arguments:

JavaScript

But I would like to decide the group used based on some logic in the controller method. Is there a way to call validation manually? Something like result = account.validate(Account.Step1.class)?

I am aware of creating your own Validator class, but that’s something I want to avoid, I would prefer to just use the annotations on the class variables themselves.

Advertisement

Answer

Spring provides LocalValidatorFactoryBean, which implements the Spring SmartValidator interface as well as the Java Bean Validation Validator interface.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement