Check if data is valid before saving the object