Skip to content

Hash Validations

Tilo edited this page Feb 2, 2018 · 3 revisions

Hash Validations come in handy if you want to check that data for certain columns is present in a record (required fields).

Hash Validations do not throw an exception, but instead add an error to the @errors hash, using the numerical file_line_count of the current line in the CSV file as the key. Check the source code.

:required_fields

This checks if any of the required fields has a non-nil, non-blank, non-zero value in the given CSV row.

:required_fields_matching

This checks if any of the required fields matches the given regular expression for the given CSV row.

Custom Hash Validations

You can define your own custom hash validations using Ruby Procs.

Here you can find the pre-defined hash validations