lib/valigator/csv/error.rb in valigator-csv-1.2.0 vs lib/valigator/csv/error.rb in valigator-csv-1.3.0
- old
+ new
@@ -4,11 +4,11 @@
end
class Error
- attr_reader :row, :type, :message
+ attr_reader :row, :type, :message, :field
def initialize(error)
case error
@@ -20,29 +20,30 @@
end
def ==(other)
- row == other.row && message == other.message && type == other.type
+ row == other.row && message == other.message && type == other.type && field == other.field
end
def to_hash
{
row: row,
type: type,
- message: message
+ message: message,
+ field: field
}
end
private
def build_from_hash(error)
- build error[:type], error[:message], error[:row]
+ build error[:type], error[:message], error[:row], error[:field]
end
def build_from_error(error)
@@ -56,13 +57,14 @@
matches[:lineno].to_i if matches
end
- def build(type, message, row)
+ def build(type, message, row, field=nil)
@type = type
@row = row
@message = message
+ @field = field
end
def map_to_type(message)