Sha256: a642fe06694bf4eaaeaadd0d960ca7d70abc78af76ff1a6515e24bcded5cbb33
Contents?: true
Size: 674 Bytes
Versions: 1
Compression:
Stored size: 674 Bytes
Contents
module Valigator module CSV module FieldValidators class Float < Integer def initialize(options = {}) @options = options end def valid?(value) formatted = formatted_value(value) formatted.to_f.to_s == formatted || super end def error_type 'invalid_float' end def error_message 'Invalid float field' end private def decimal_mark @options[:decimal_mark] end def formatted_value(value) decimal_mark ? value.gsub(decimal_mark, '.') : value end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valigator-csv-1.3.0 | lib/valigator/csv/field_validators/float.rb |