Sha256: 5f07fef544ea3eb4daee7044e123517b9e48f119f479ea61628c9bb822f3b8e5

Contents?: true

Size: 447 Bytes

Versions: 1

Compression:

Stored size: 447 Bytes

Contents

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

      def validate_param!(attr_name, params)
        unless params.respond_to?(:has_key?) && params.has_key?(attr_name)
          raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message_key: :presence
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-0.7.0 lib/grape/validations/presence.rb