csv-column-validator
Service icon

CSV Column Validator

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 29 Sep (12 hours ago)
 by 
0.0
 (0 ratings)
csv-column-validator

CSV Column Validator

Documentation
1.0.0

Overview

CSV Column Validator is an OutSystems utility component for validating the structure of a CSV file before it is processed, imported, or passed to downstream workflows.

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 CSV, identifies missing required columns, reports unexpected columns, and provides a validation result and error information.


Features

  • Validate CSV header columns against a list of required columns.
  • Support configurable single-character CSV delimiters.
  • Support case-sensitive and case-insensitive column comparison.
  • Optionally trim leading and trailing spaces from column names.
  • Detect empty column names.
  • Detect duplicate column names in the CSV header.
  • Detect duplicate required column definitions.
  • Identify missing required columns.
  • Identify unexpected columns.
  • Support UTF-8 CSV content.
  • Remove a UTF-8 BOM when present.
  • Support quoted CSV header values.
  • Support delimiters inside quoted column values.
  • Support escaped double quotes inside quoted column values.
  • Return descriptive error messages for invalid or malformed CSV headers.

Available Action

ValidateCSVColumns

Validates the column structure of a CSV file against a specified list of required columns.

Inputs

ParameterTypeDescription
CSVContentBinary DataThe binary content of the CSV file to validate.
RequiredColumnsTextComma-separated list of column names that are required in the CSV header.
DelimiterTextSingle-character delimiter used to separate CSV columns. If empty, comma (,) is used by default.
CaseSensitiveBooleanDetermines whether column-name comparison is case-sensitive.
TrimColumnNamesBooleanDetermines whether leading and trailing spaces are removed from column names before comparison.

Outputs

ParameterTypeDescription
IsValidBooleanIndicates whether all required columns are present in the CSV header.
FoundColumnsTextComma-separated list of column names detected in the CSV header.
MissingColumnsTextComma-separated list of required columns that are not present in the CSV header.
UnexpectedColumnsTextComma-separated list of columns found in the CSV header that are not included in the required-column list.
ErrorMessageTextContains technical or structural error information when validation cannot be completed.

Input Details

CSVContent

Provide the CSV file as Binary Data.

Example:

CSV file
    ↓
Binary Data
    ↓
ValidateCSVColumns

The component returns an error when the supplied content is empty.


RequiredColumns

Provide the required column names as a comma-separated list.

Example:

id,first_name,email,salary

The required-column list is independent of the CSV delimiter.

For example, even when the CSV uses:

;

the required columns can still be supplied as:

id,first_name,email,salary

Delimiter

Specifies the character used to separate columns in the CSV.

Examples:

,
;
|

If no delimiter is provided, the component uses:

,

The delimiter must contain exactly one character.


CaseSensitive

Controls how column names are compared.

True

Comparison is case-sensitive:

Email ≠ email

False

Comparison is case-insensitive:

Email = email

TrimColumnNames

Controls whether leading and trailing spaces are removed from column names.

True

" salary "

is treated as:

"salary"

False

The original spacing is retained.


Validation Behavior

The component first reads the first CSV row as the header row.

It then:

  1. Validates the CSV content.
  2. Validates the required-column input.
  3. Applies the configured delimiter.
  4. Decodes the CSV as UTF-8.
  5. Removes a UTF-8 BOM when present.
  6. Parses the header row.
  7. Trims column names when requested.
  8. Checks for empty column names.
  9. Checks for duplicate CSV column names.
  10. Checks for duplicate required columns.
  11. Determines missing required columns.
  12. Determines unexpected columns.
  13. Returns the validation result.

Understanding IsValid

IsValid is set to True when all required columns are present in the CSV header.

Unexpected columns do not make the validation invalid.

Example

CSV:

id,first_name,last_name,email,age,city,salary,joined

Required columns:

salary,city

Result:

IsValid = True
MissingColumns = ""
UnexpectedColumns = id,first_name,last_name,email,age,joined

This allows applications to require specific columns while still accepting additional columns.


Missing Columns

A required column that does not exist in the CSV header is returned through MissingColumns.

Example

CSV:

id,first_name,last_name,email,age,city,salary,joined

Required:

salary,country

Result:

IsValid = False
MissingColumns = country

This is considered a validation result, not a technical error, so ErrorMessage remains empty.


Unexpected Columns

Columns found in the CSV but not listed as required are returned through UnexpectedColumns.

Example

CSV:

id,name,email,city

Required:

name,email

Result:

UnexpectedColumns = id,city

Unexpected columns are informational and do not cause IsValid to become false.


Duplicate Column Detection

The component checks for duplicate column names in both:

  • The CSV header
  • The required-column definition

Duplicate detection respects the CaseSensitive setting.

Example

CSV header:

id,name,email,email

The component returns an error similar to:

CSV contains duplicate column names: email

Likewise, duplicate required columns such as:

name,email,name

are rejected.


Empty Column Detection

The component rejects headers containing empty column names.

Example:

id,,email

Result:

CSV contains one or more empty column names.

Quoted Column Names

The header parser supports quoted values.

For example:

"Customer, Name",Age,City

is interpreted as:

Customer, Name
Age
City

The comma inside "Customer, Name" is treated as part of the column name rather than as a delimiter.

Escaped quotes are also handled.

Example:

"Customer ""Primary"" Name",Age

UTF-8 Support

The component expects CSV content encoded as UTF-8.

A UTF-8 Byte Order Mark (BOM) is automatically removed when present so that it does not become part of the first column name.


Error Handling

The component uses ErrorMessage for technical or structural failures.

Examples include:

CSV content is empty.
Required columns were not provided.
Delimiter must contain exactly one character.
CSV header row is empty.
CSV contains one or more empty column names.
CSV contains duplicate column names: ...
Required columns contain duplicates: ...
CSV header contains an unclosed quoted value.

Missing required columns are not treated as technical errors. They are returned through:

IsValid
MissingColumns

Recommended Usage

A typical application flow is:

Upload CSV
    ↓
ValidateCSVColumns
    ↓
IsValid?
   ┌───────┴────────┐
  Yes              No
   ↓                ↓
Process CSV      Display missing
                 / validation info

For example:

ValidateCSVColumns
        ↓
If(IsValid)
        ↓
Continue CSV processing

For an invalid file:

MissingColumns
UnexpectedColumns
ErrorMessage

can be displayed to the user or logged for troubleshooting.


Example 1 — Valid CSV

CSV Header

id,first_name,last_name,email,age,city,salary,joined

Required Columns

salary,city

Settings

Delimiter = ,
CaseSensitive = True
TrimColumnNames = True

Result

IsValid = True

FoundColumns =
id,first_name,last_name,email,age,city,salary,joined

MissingColumns =

UnexpectedColumns =
id,first_name,last_name,email,age,joined

ErrorMessage =

Example 2 — Missing Required Column

CSV Header

id,first_name,last_name,email,age,city,salary,joined

Required Columns

salary,country

Result

IsValid = False

MissingColumns =
country

The application can use this result to inform the user that the uploaded CSV does not contain all required columns.


Example 3 — Case-Insensitive Validation

CSV:

id,Name,Email

Required:

name,email

With:

CaseSensitive = False

the columns match successfully.

With:

CaseSensitive = True

Name and name are treated as different column names.


Example 4 — Custom Delimiter

CSV:

id;name;email;city

Use:

Delimiter = ;

Required columns:

name,email

The component correctly parses the header using ; as the delimiter.


Demo Application

A dedicated CSVColumnValidatorDemo application is included to demonstrate the component.

The demo allows users to:

  • Select a CSV file.
  • Enter the CSV delimiter.
  • Enter required columns.
  • Enable or disable case-sensitive comparison.
  • Enable or disable column-name trimming.
  • Execute validation.
  • View the detected columns.
  • View missing columns.
  • View unexpected columns.
  • View the overall validation result.

The demo includes examples of both successful and unsuccessful validation scenarios.


Limitations

The component validates the CSV header structure only.

It does not validate:

  • Data types
  • Required data values
  • Individual row contents
  • Date formats
  • Numeric formats
  • Business rules
  • Data quality

It also reads the first CSV line as the header row, so it is intended for CSV files whose header is contained in the first row.