Sha256: 7552d149eb6fd3123a4e348dd31a3c326e4185636be98109513fe79226c859a0

Contents?: true

Size: 436 Bytes

Versions: 5

Compression:

Stored size: 436 Bytes

Contents

module Grape
  module Validations
    class PresenceValidator < Base
      def validate!(params)
        return unless @scope.should_validate?(params)
        super
      end

      def validate_param!(attr_name, params)
        unless params.respond_to?(:key?) && params.key?(attr_name)
          fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message_key: :presence
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-0.13.0 lib/grape/validations/validators/presence.rb
grape-0.12.0 lib/grape/validations/validators/presence.rb
grape-0.11.0 lib/grape/validations/validators/presence.rb
grape-0.10.1 lib/grape/validations/validators/presence.rb
grape-0.10.0 lib/grape/validations/validators/presence.rb