I have a DTO with two entity. How can I validate these entities? What annotation should I use? I use rest api, JSON, spring boot. I know how to validate one entity. But I don't know what to do with DTO.
@PostMapping
public ResponseEntity<?> create(@Valid @RequestBody DTOClient client) {
....
return responseEntity;
}
public class DTOClient{
//What I should use here to validate these entities?
private Client client;
private Skill skill;
}
@Entity
public class Client{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String first_name;
private String last_name;
}
@Entity
public class Skill{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private int year;
}