Module: Csv2hash::Validator

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

Defined Under Namespace

Modules: Collection, Mapping

Instance Method Summary collapse

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


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

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

#validate_rules(y = nil) ⇒ Object



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

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