Sha256: e6ec99f56ec0edfa0e9f6efb9d9ad57183d3c6885250d9e36408a0cb80c5bf58
Contents?: true
Size: 813 Bytes
Versions: 2
Compression:
Stored size: 813 Bytes
Contents
# require 'active_support/core_ext' module Csv2hash::StructureValidator class ValidationError < StandardError ; end def validate_structure! definition.structure_rules.each do |rule, options| begin rule_instance(rule, options).validate! data_source rescue => e self.errors << { y: nil, x: nil, message: e.message, key: nil } raise if break_on_failure end end end def rule_instance rule, options Csv2hash::StructureValidator.const_get(rule).new(options) # 'min_columns'.camelize.constantize.new end module Validator def validate! source source.index { |line| validate_line line }.tap do |line| raise Csv2hash::StructureValidator::ValidationError, error_message(line) unless line.nil? end true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
csv2hash-0.5.0 | lib/csv2hash/structure_validator.rb |
csv2hash-0.4.0 | lib/csv2hash/structure_validator.rb |