class LIVR::Rules::Numeric::PositiveDecimal

Public Instance Methods

call(value, user_data, field_results) click to toggle source
# File lib/livr/rules/numeric.rb, line 51
def call(value, user_data, field_results)
  return if is_no_value(value)
  return 'FORMAT_ERROR' if !is_primitive(value)

  value_float = Float(value.to_s) rescue nil
  return "NOT_POSITIVE_DECIMAL" if value_float.nil?
  return "NOT_POSITIVE_DECIMAL" unless value_float.positive?

  field_results << value_float
  return
end