Sha256: 51457d4cee6613f9fcf435398b13e89d58e8047f82fbeaa3d97687cde054dd22

Contents?: true

Size: 305 Bytes

Versions: 2

Compression:

Stored size: 305 Bytes

Contents

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

    def error_message
      "params[#{key.inspect}] must be an Integer"
    end

    private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
weak_parameters-0.0.8 lib/weak_parameters/integer_validator.rb
weak_parameters-0.0.7 lib/weak_parameters/integer_validator.rb