Skip to content
Advertisement

spring combine two validation annotations in one

I’m using Spring+Hibernate+Spring-MVC.
I want to define a custom constraint combining two other predefined validation annotations: @NotNull @Size like this:

JavaScript

and I want to use this annotation in my form models.

JavaScript

UserController.java

JavaScript

But it does not work. It accepts the less than 4 character passwords.
How can I solve this problem?

Advertisement

Answer

This is a bit late, but technique of combining validation annotations described in

https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/?v=5.4#section-constraint-composition

Maybe it was not available, at the time of writing, but solution is following

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