Sha256: 3db8a67a031e1227a1ea562ec5bcd8056cf58e3be472a3dd22067159fdedc9e2
Contents?: true
Size: 461 Bytes
Versions: 5
Compression:
Stored size: 461 Bytes
Contents
# frozen_string_literal: true module InferModel class Parsers::Decimal extend Callable extend Dry::Initializer param :value option :allow_blank, default: -> { true } def call raise Parsers::Error, "value was blank which is not allowed" if value.nil? && !allow_blank return if value.nil? || value.empty? Float(value) rescue ArgumentError raise Parsers::Error, "'#{value}' is not a Decimal" end end end
Version data entries
5 entries across 5 versions & 1 rubygems