Tutorial by Examples

Add any JSR 303 implementation to your classpath. Popular one used is Hibernate validator from Hibernate. <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.2.0.Final</version> </dependen...
Suppose we have a simple class with validation annotations public class UserDTO { @NotEmpty private String name; @Min(18) private int age; //getters/setters } A controller to check the UserDTO validity. @RestController public class ValidationController { @Reque...
Suppose we have a POJO class User we need to validate. public class User { @NotEmpty @Size(min=5) @Email private String email; } and a controller method to validate the user instance public String registerUser(@Valid User user, BindingResult result); Let's extend the U...

Page 1 of 1