Sha256: d2a4c4ce030bc8ab574732560fb6cfa62859ccc4a50a9380619a702dc3804ed3

Contents?: true

Size: 439 Bytes

Versions: 2

Compression:

Stored size: 439 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?(:key?) && params.key?(attr_name)
          raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message_key: :presence
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
grape-security-0.8.0 lib/grape/validations/presence.rb
grape-0.8.0 lib/grape/validations/presence.rb