lib/csv2hash/validator.rb in csv2hash-0.6.1 vs lib/csv2hash/validator.rb in csv2hash-0.6.2

- old
+ new

@@ -1,10 +1,14 @@ +require_relative 'discover' + module Csv2hash module Validator + include Discover def validate_rules y=nil - # binding.pry + find_positions! + definition.cells.each do |cell| _y, x = position cell.rules.fetch(:position) begin validate_cell (_y||y), x, cell rescue => e @@ -20,10 +24,10 @@ def validate_cell y, x, cell value = data_source[y][x] rescue nil begin raise unless value unless cell.rules.fetch :allow_blank - if (extra_validator = cell.rules.fetch :extra_validator) && extra_validator.kind_of?(Csv2hash::ExtraValidator) + if (extra_validator = cell.rules.fetch :extra_validator) && extra_validator.kind_of?(ExtraValidator) raise unless extra_validator.valid? cell.rules, value else if value && (values = cell.rules.fetch :values) if values.class == Range raise unless values.include?(value.to_f)