Sha256: 749bc47746707c37d5b4861b878791aaa2a3f8ce228f511cbd5f3f9d5ec2bf9d

Contents?: true

Size: 430 Bytes

Versions: 4

Compression:

Stored size: 430 Bytes

Contents

module Grape
  module Kaminari
    class MaxValueValidator < Grape::Validations::SingleOptionValidator
      def validate_param!(attr_name, params)
        return unless params[attr_name]

        attr = params[attr_name]
        if attr && @option && attr > @option
          raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message: "must be less than #{@option}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-kaminari-0.1.5 lib/grape/kaminari/max_value_validator.rb
grape-kaminari-0.1.3 lib/grape/kaminari/max_value_validator.rb
grape-kaminari-0.1.2 lib/grape/kaminari/max_value_validator.rb
grape-kaminari-0.1.1 lib/grape/kaminari/max_value_validator.rb