Class: FloatFormatValidator

Inherits:
CsvRowModel::Validators::NumberValidator show all
Defined in:
lib/csv_row_model/validators/float_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/float_format.rb', line 2

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

  return if value.present? && value.to_f.to_s =~ /#{before}\.#{after.present? ? after : 0}/

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