Sha256: 857111de188b832e6c915276cce1ee0b610532d81299712278b54a7d4df9ad43
Contents?: true
Size: 728 Bytes
Versions: 11
Compression:
Stored size: 728 Bytes
Contents
module Valigator module CSV module FieldValidators class Float < Integer def valid?(value) super || value.is_a?(::Float) || formatted_float?(value) end def error_type 'invalid_float' end def error_message 'Invalid float field' end private def decimal_mark @options[:decimal_mark] end def formatted_float?(value) Float(formatted_value(value)) true rescue ArgumentError, TypeError false end def formatted_value(value) decimal_mark ? value.to_s.gsub(decimal_mark, '.') : value end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems