CSV Column Validator is an OutSystems component that validates the column structure of a CSV file before it is processed or imported by an application.
The component reads the first row of the CSV as the header row and compares the detected column names against a user-defined list of required columns. It returns the columns found in the file, identifies missing required columns, reports unexpected columns, and provides a validation result and error information.
,
;
ValidateCSVColumns
Validates the column structure of the supplied CSV file.
Inputs
CSVContent
RequiredColumns
Delimiter
CaseSensitive
TrimColumnNames
Outputs
IsValid
FoundColumns
MissingColumns
UnexpectedColumns
ErrorMessage
IsValid is set to True when all required columns are present in the CSV header.
Unexpected columns are reported separately through UnexpectedColumns and do not, by themselves, make the validation invalid. This allows applications to accept CSV files that contain additional columns while still enforcing the presence of required columns.
Structural problems such as empty column names, duplicate CSV columns, duplicate required columns, invalid delimiters, empty CSV content, or malformed quoted header values are returned through ErrorMessage.
Given the CSV header:
id,first_name,last_name,email,age,city,salary,joined
and required columns:
salary,city
the component returns:
IsValid = True
FoundColumns = id,first_name,last_name,email,age,city,salary,joined
MissingColumns =
UnexpectedColumns = id,first_name,last_name,email,age,joined
If a required column such as country is not present, the component returns:
country
IsValid = False
MissingColumns = country
UnexpectedColumns contains the columns present in the CSV that were not required.
When CaseSensitive is enabled, column names are compared using case-sensitive matching.
For example:
Email ? email
Email
email
When CaseSensitive is disabled, the comparison is case-insensitive:
Email = email
When TrimColumnNames is enabled, spaces around column names are removed before validation.
salary is treated as:
salary
The component supports quoted header values and correctly handles delimiters inside quoted values.
"Customer, Name",Age,City
is interpreted as three columns:
Customer, NameAgeCity
Customer, Name
Age
City
Escaped double quotes inside quoted column names are also supported.
CSV Column Validator can be used before importing or processing CSV files in scenarios such as:
A dedicated demo application is included to demonstrate the component's validation behavior. The demo allows users to provide a CSV file, define the delimiter and required columns, configure case sensitivity and column-name trimming, and view the validation results.
The demo displays:
The example scenarios demonstrate both successful validation and validation failures when required columns are missing.
The component validates the first CSV header row and does not validate the data rows themselves. It is intended for validating CSV column structure before subsequent processing.
RequiredColumns is provided as a comma-separated list independently of the CSV Delimiter. For example, a semicolon-delimited CSV can still use Name,Age,Email as the required-column definition.
Name,Age,Email
CSV Column Validator provides a lightweight way to validate CSV structure in OutSystems before allowing the file to proceed to downstream processing.