I have an entity. I use rest controller. My goal is to validate all fields in the coming JSON object. If I find one or more incorrect fields, I need to return all incorrect fields. How can I do it with spring? Should I check every field in try - catch?
@Entity
public class Client {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Size(min = 4, message = "Min length 4")
private String first_name;
@Size(min = 4, message = "Min length 4")
private String last_name;
@Size(min = 4, message = "Min length 4")
private String fathers_name;
}