-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Describe the bug
In ./docs/Usage-Guide.md, many contact columns are marked as optional. However, if you try to import a CSV that lacks these columns, e.g. ContactLastName or ContactAddress1, the contacts are not imported, and CsvHelper logs an error like the following:
CsvHelper.HeaderValidationException: Header with name 'ContactLastName'[0] was not found.
Headers: 'ContactGUID', 'ContactCreated', 'ContactFirstName', 'ContactEmail', 'ContactAddress1', 'ContactMiddleName'
If you are expecting some headers to be missing and want to ignore this validation, set the configuration HeaderValidated to null. You can also change the functionality to do something else, like logging the issue.
If you're using the source code of this repo, you can change the CsvConfiguration object, setting both
HeaderValidated = null, and MissingFieldFound = null,. However, if you are using the package instead, this is not possible.
To Reproduce
Steps to reproduce the behavior:
- Download the sample CSV file from this repo
- Edit the file to remove the ContactAddress1 column, or a different optional column
- Import the CSV
Expected behavior
The optional columns should not cause an exception that prevents the contacts from importing
Next steps
We should investigate the CSV Helper code and how we are setting it up to parse the file. If there is no way to make these columns optional there, we could check configuration for some key that will tell our code to set HeaderValidated and MissingFieldFound to null.