Module: CSVDecision::Validate Private
- Defined in:
- lib/csv_decision/validate.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Parse and validate the column names in the header row. These methods are only required at table load time.
Class Method Summary collapse
-
.column(cell:, index:) ⇒ Array<(Symbol, Symbol)>
private
Validate a column header cell and return its type and name.
-
.name(columns:, name:, out:) ⇒ void
private
Validate the column name against the dictionary of column names.
Class Method Details
.column(cell:, index:) ⇒ Array<(Symbol, Symbol)>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validate a column header cell and return its type and name.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/csv_decision/validate.rb', line 21 def self.column(cell:, index:) match = Header::COLUMN_TYPE.match(cell) raise CellValidationError, 'column name is not well formed' unless match column_type = match['type']&.downcase&.to_sym column_name = column_name(type: column_type, name: match['name'], index: index) [column_type, column_name] rescue CellValidationError => exp raise CellValidationError, "header column '#{cell}' is not valid as the #{exp.}" end |
.name(columns:, name:, out:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Validate the column name against the dictionary of column names.
41 42 43 44 45 46 |
# File 'lib/csv_decision/validate.rb', line 41 def self.name(columns:, name:, out:) return unless (in_out = columns[name]) return validate_out_name(in_out: in_out, name: name) if out validate_in_name(in_out: in_out, name: name) end |