Sha256: 4631d3030705075aa423713216ce3948deb0c238aace672adb6c1ad3c3ac81b8

Contents?: true

Size: 281 Bytes

Versions: 5

Compression:

Stored size: 281 Bytes

Contents

module InputSanitizer
  class PositiveIntegerConverter < V1::IntegerConverter
    def call(value)
      super.tap { |value| raise_error if value <= 0 }
    end

    private
    def raise_error
      raise ConversionError.new("invalid integer (neagtive or zero)")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
input_sanitizer-0.6.0 lib/input_sanitizer/extended_converters/positive_integer_converter.rb
input_sanitizer-0.5.0 lib/input_sanitizer/extended_converters/positive_integer_converter.rb
input_sanitizer-0.4.1 lib/input_sanitizer/extended_converters/positive_integer_converter.rb
input_sanitizer-0.4.0 lib/input_sanitizer/extended_converters/positive_integer_converter.rb
input_sanitizer-0.3.33 lib/input_sanitizer/extended_converters/positive_integer_converter.rb