Sha256: 529250c8ee57edf40808ac46e3c9e1d127baae88bc2e0410a20d12bf478ea8ac

Contents?: true

Size: 337 Bytes

Versions: 17

Compression:

Stored size: 337 Bytes

Contents

class FloatFormatValidator < CsvRowModel::Validators::NumberValidator # :nodoc:
  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
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
csv_row_model-1.0.0.beta1 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.4.1 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.4.0 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.10 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.9 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.8 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.7 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.6 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.5 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.4 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.3 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.2 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.1 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.3.0 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.2.1 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.1.1 lib/csv_row_model/validators/float_format.rb
csv_row_model-0.1.0 lib/csv_row_model/validators/float_format.rb