Refactor the validation of the added and modified entities.