Refactor addValidationError slightly to allow passing null for the field