class Valigator::CSV::FieldValidators::Float
Public Instance Methods
error_message()
click to toggle source
# File lib/valigator/csv/field_validators/float.rb, line 18 def error_message 'Invalid float field' end
error_type()
click to toggle source
# File lib/valigator/csv/field_validators/float.rb, line 12 def error_type 'invalid_float' end
valid?(value)
click to toggle source
Calls superclass method
# File lib/valigator/csv/field_validators/float.rb, line 6 def valid?(value) super || value.is_a?(::Float) || formatted_float?(value) end
Private Instance Methods
decimal_mark()
click to toggle source
# File lib/valigator/csv/field_validators/float.rb, line 26 def decimal_mark @options[:decimal_mark] end
formatted_float?(value)
click to toggle source
# File lib/valigator/csv/field_validators/float.rb, line 32 def formatted_float?(value) Float(formatted_value(value)) true rescue ArgumentError, TypeError false end
formatted_value(value)
click to toggle source
# File lib/valigator/csv/field_validators/float.rb, line 41 def formatted_value(value) decimal_mark ? value.to_s.gsub(decimal_mark, '.') : value end