lib/csv2hash/validator.rb in csv2hash-0.7.5 vs lib/csv2hash/validator.rb in csv2hash-0.7.6
- old
+ new
@@ -52,13 +52,14 @@
def extra_validator? cell
(extra_validator = cell.rules.fetch(:extra_validator)) && extra_validator.kind_of?(ExtraValidator)
end
def verify_extra_validator! cell, value
+ return :no_extra_validation_with_empty_value unless value.present?
raise unless cell.rules.fetch(:extra_validator).valid? cell.rules, value
end
-
+
def verify_blank! cell, value
raise unless value.present? || cell.rules.fetch(:allow_blank)
end
def has_valid_values? cell, value
@@ -75,10 +76,10 @@
end
end
def valid_values_include? values, value, case_sensitive
case_sensitive ? values.include?(value) : values.any?{ |v| v.casecmp(value)==0 }
- end
+ end
def find_or_remove_dynamic_fields_on_mapping!
cells = definition.cells.dup
# cells without optional and not found dynamic field
definition.cells = [].tap do |_cells|