Sha256: ff6726cca8ee3961d6fa8a753c215f8481fa897f778484eff938039a1fe68ae8

Contents?: true

Size: 310 Bytes

Versions: 1

Compression:

Stored size: 310 Bytes

Contents

module WeakParameters
  class FloatValidator < WeakParameters::BaseValidator
    def valid_type?
      /\A-?\d+(?:\.\d+)?\z/ === params[key].to_s
    end

    def error_message
      "params[#{key.inspect}] must be a Float"
    end

    private

    def value
      super.presence.try(:to_f)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weak_parameters-0.0.8 lib/weak_parameters/float_validator.rb