Sha256: 0fad05a14f540880ffa0f3b784fc8d85ffcb50b4bfbcbb5d4a2cdd545fc26159
Contents?: true
Size: 695 Bytes
Versions: 1
Compression:
Stored size: 695 Bytes
Contents
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 << e.message raise if exception_mode end end def rule_instance rule, options Csv2hash::StructureValidator.const_get(rule).new(options) end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv2hash-0.2.0 | lib/csv2hash/structure_validator.rb |