Module: Csv2hash::Validator
- Includes:
- Discover
- 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)
Methods included from Discover
#find_positions!
Instance Method Details
- (Boolean) valid?
21
|
# File 'lib/csv2hash/validator.rb', line 21
def valid?() self.errors.empty?; end
|
- (Object) validate_rules(y = nil)
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/csv2hash/validator.rb', line 7
def validate_rules y=nil
find_positions!
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
|