entity validation and constraints good example