Take the 2-minute tour ×  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?  share|improve this
question What language are you coding in? –  hbrock Oct 23 '12
at 21:53 it is not a good practice to have the validation in
you'r domain classes. If you want the data to be validated on
the client side it would be better to create a viewmodel and
user the data annotations attribute in the view model. Or create
a separate layer for validating your data before saving it to
the database –  CoffeeCode Oct 23 '12 at 21:57 @CoffeeCode I
disagree. The domain must be valid and consistent