Class: IntegerFormatValidator

Inherits:
CsvRowModel::Validators::NumberValidator show all
Defined in:
lib/csv_row_model/validators/integer_format.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from CsvRowModel::Validators::NumberValidator

#before_after_decimal

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/csv_row_model/validators/integer_format.rb', line 2

def validate_each(record, attribute, value)
  before, after = before_after_decimal(value)

  return if value.to_i.to_s == before && after.empty?

  record.errors.add(attribute, 'is not a Integer format')
end