Can data classes contain methods for validation?
- by Arturas M
OK, say I have a data class for a user:
public class User {
private String firstName;
private String lastName;
private long personCode;
private Date birthDate;
private Gender gender;
private String email;
private String password;
Now let's say I want to validate email, whether names are not empty, whether birth date is in normal range, etc. Can I put that validation method in this class together with data? Or should it be in UserManager which in my case handles the lists of these users?