Module: Csv2hash::StructureValidator
- Includes:
- Deprecation
- Included in:
- Main
- Defined in:
- lib/csv2hash/structure_validator.rb,
lib/csv2hash/structure_validator/max_columns.rb,
lib/csv2hash/structure_validator/min_columns.rb,
lib/csv2hash/structure_validator/deprecation.rb
Defined Under Namespace
Modules: Deprecation, Validator Classes: MaxColumns, MinColumns, ValidationError
Constant Summary
- MAX_COLUMN =
'max_columns'.freeze
- MIN_COLUMN =
'min_columns'.freeze
- RULES_NAME =
[ MIN_COLUMN, MAX_COLUMN ]
Constants included from Deprecation
Deprecation::NEW_SYNTAX, Deprecation::OLD_MAX_COLUMN, Deprecation::OLD_MIN_COLUMN, Deprecation::OLD_RULES_NAME
Instance Method Summary (collapse)
Methods included from Deprecation
Instance Method Details
- (Object) rule_instance(rule, options)
26 27 28 29 30 31 32 33 |
# File 'lib/csv2hash/structure_validator.rb', line 26 def rule_instance rule, _rule = check_params rule begin StructureValidator.const_get(_rule.camelize).new() rescue NameError => e raise "Structure rule #{rule} unknow, please use one of these #{RULES_NAME}" end end |
- (Object) validate_structure!
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/csv2hash/structure_validator.rb', line 15 def validate_structure! definition.structure_rules.each do |rule, | begin rule_instance(rule, ).validate! data_source rescue => e self.errors << { y: nil, x: nil, message: e., key: nil } raise if break_on_failure end end end |