The existing implementation required header and data columns to be in a specific order. However, any order should be allowed.
Solution
Instead of checking the columns in order against the list of required columns, the list of required columns has its entries removed as the column names are found within the provided data. If there are no required columns left at the end, then all required columns are present, and there are no errors. If any required columns are left, one error is produced for each missing required column.
Result
The HEADER_COLUMN_COUNT error has been removed, since it is no longer being used. Rather than giving an error about the number of columns, each missing header column results in an error from HEADER_COLUMN_MISSING. A similar change is made for the data columns, removing COLUMN_COUNT and adding COLUMN_MISSING. A CSV with its header and data columns in an arbitrary order may be considered valid as long as the required columns are all present.
The change to this behavior is made for both 1.1 and 2.0 versions of the csv validation code.
Test Plan
Tests for validateHeaderColumns and validateColumns are updated.
Problem
The existing implementation required header and data columns to be in a specific order. However, any order should be allowed.
Solution
Instead of checking the columns in order against the list of required columns, the list of required columns has its entries removed as the column names are found within the provided data. If there are no required columns left at the end, then all required columns are present, and there are no errors. If any required columns are left, one error is produced for each missing required column.
Result
The
HEADER_COLUMN_COUNT
error has been removed, since it is no longer being used. Rather than giving an error about the number of columns, each missing header column results in an error fromHEADER_COLUMN_MISSING
. A similar change is made for the data columns, removingCOLUMN_COUNT
and addingCOLUMN_MISSING
. A CSV with its header and data columns in an arbitrary order may be considered valid as long as the required columns are all present.The change to this behavior is made for both 1.1 and 2.0 versions of the csv validation code.
Test Plan
Tests for validateHeaderColumns and validateColumns are updated.