Module: Csv2hash::Validator

Included in:
Collection, Mapping
Defined in:
lib/csv2hash/validator.rb

Defined Under Namespace

Modules: Collection, Mapping

Instance Method Summary collapse

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


16
# File 'lib/csv2hash/validator.rb', line 16

def valid?() self.errors.empty?; end

#validate_rules(y = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/csv2hash/validator.rb', line 4

def validate_rules y=nil
  definition.rules.each do |rule|
    _y, x = position rule.fetch(:position)
    begin
      validate_cell (_y||y), x, rule
    rescue => e
      self.errors << { y: (_y||y), x: x, message: e.message, key: rule.fetch(:key) }
      raise if exception_mode
    end
  end
end