I've created a DTO with some properties with validation constraint (like all the properties must be present in JSON Object). Now, I want to make that DTO in a way like if a particular property is missing in JSON Object, it causes no error.
public class UserDTO{
private String name;
private String address;
private String email;
private String mobileNumber;
}
Now the JSON Object which I want to work could be like this (with missing email).
{
name:"Hamza",
address:"ABC",
mobileNumber:"12345"
}
What should be done? Is there any annotation which makes the field optional?