Sha256: 647b2c0594c52145e0caa1832cc177ef81886ac7342aeb68635c926143c8fa03

Contents?: true

Size: 444 Bytes

Versions: 4

Compression:

Stored size: 444 Bytes

Contents

module Grape
  module Kaminari
    class MaxValueValidator < Grape::Validations::Validators::Base
      def validate_param!(attr_name, params)
        attr = params[attr_name]
        return unless attr.is_a?(Integer) && @option && attr > @option

        raise Grape::Exceptions::Validation.new(
          params: [@scope.full_name(attr_name)],
          message: "must be less than or equal #{@option}",
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-kaminari-0.4.5 lib/grape/kaminari/max_value_validator.rb
grape-kaminari-0.4.4 lib/grape/kaminari/max_value_validator.rb
grape-kaminari-0.4.3 lib/grape/kaminari/max_value_validator.rb
grape-kaminari-0.4.2 lib/grape/kaminari/max_value_validator.rb